Reputation: 8461
I have a Message
model and it has a send_at
attribute that logs the time it was sent. In the console I'm trying to find the messages that are set for the future. Now I'm putting in the command Message.where(send_at: < Time.now)
This is getting an error and I really didn't expect it to work. Does anybody know what the proper command would be for this query.
Upvotes: 1
Views: 1920
Reputation: 619
Activerecord:
Message.where("send_at < ?", Time.now)
Mongoid:
Message.where(:send_at.lt => Time.now)
I am writing this off the top of my head but the idea is that.
Upvotes: 2
Reputation: 121000
Use the SQL-side query:
Message.where('send_at < NOW()')
Upvotes: 2