开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜