Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写 rake 任务,但无法让我的代码正常工作。可以这样写吗?
Model.where('(? - begins_at)/3600 > ?', Time.now, 2).all
我想要实现的是向我返回超过 2 小时的记录列表
试试看:
Model.where('begins_at < ?', Time.zone.now - 2.hours).all
试试这个:
Model.where(['(? - begins_at) > ?', Time.now, 1]).all
根据您的评论,您可以这样做:
Model.where('begins_at < ?', Time.now - 2.hours).all