Compare updated_at in Rails
time_shift = DateTime.now - 75000
@user.items.where(:updated_at < time_shift) { |item|
I get error
com开发者_如何学Cparison of Symbol with DateTime failed
Why and how to fix it?
In model:
t.datetime "updated_at"
try
@user.items.where("updated_at < ?", time_shift)
John's answer doesn't seems to work with PostgreSQL. If you are using PostgreSQL use:
@user.items.where('"users"."updated_at" < ?', time_shift)
精彩评论