class Request
include Mongoid::Document
field :code, type: String
validates :code, :presence => true,
:inclusion => { :in => proc { Listing.all_codes } }
Using Mongoid, I am trying to validate the :code input on the submission form to make sure they are using a proper code that is already in the database. The listing model :code field is also named :code.
This is the error:
undefined method `all_codes' for Listing:Class
Any suggestions? What is the reference equivalent in Mongoid?