views:

36

answers:

2

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

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

Meaning... If the record.updated_at was over 15 minutes ago, do some stuff...

This doesn't seem to be working. Ideas?

+4  A: 

You want:

if record.updated_at < 15.minutes.ago

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

Steve Ross
+1  A: 

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.

jwarchol