开发者

Rails 3 - Time Comparison?

开发者 https://www.devze.com 2023-01-22 17:24 出处:网络
I\'m working to do the following in my Rails App: if record.updated_at > 15.minutes.ago do some stuff end

I'm working to do the following in my Rails App:

if record.updated_at > 15.minutes.ago do some stuff end

Me开发者_C百科aning... If the record.updated_at was over 15 minutes ago, do some stuff...

This doesn't seem to be working. Ideas?


You want:

if record.updated_at < 15.minutes.ago

That's "less-than" as in "before".


Greater than or less than should work, depending on which you mean. 15.minutes.ago returns a time object that should compare properly with record.updated_at. When you say it "doesn't seem to be working", could you be more specific? Also, if you could show a few more lines of code it may help. For example, if you're doing this all on one line then you're missing some syntax.

0

精彩评论

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