I need to create a named object in Mongoid that compares two Time fields in one document. For instance,
scope :foo, :where => {:updated_at.gt => :checked_at}
This, obviously, will not work, since it is considered :checked_atas a symbol, not an actual field. Any suggestions on how to do this?
Update 1
Here is my model where I declare this area, with lots of redundant code.
class User
include Mongoid::Document
include Mongoid::Paranoia
include Mongoid::Timestamps
field :checked_at, :type => Time
scope :unresolved, :where => { :updated_at.gt => self.checked_at }
end
This gives me the following error:
'<class:User>': undefined method 'checked_at' for User:Class (NoMethodError)
source
share