人们可以随着时间范围这样搜索模式搜寻有时间范围的替代模式
User.where("updated_at = :updated_at and status != :status",
updated_at: previous_update..now, status: "employee")
而且事实证明,
User.where("updated_at = :updated_at", updated_at: previous_update..now)
不起作用。看起来像应该以某种方式转换为sql格式,然后才能像这样替换。或者,有更好的方式来表达上面的复杂查询?
编辑
我用Jon's suggestion到链where
过滤器:
now = Time.now
updates = User.where(updated_at: previous_update..now)
employee_updates = updates.where(status: "employee")
non_employee_updates = updates.where('status != :status', status: "employee")
感谢您的回复。在我目前的应用程序中,我想确切地知道“现在”。但是这种方法可能适用于另一种情况。 – Adobe