Time expiration code

I want to create a simple one-line function (to be used by a
before_filter) that expires the session[:updated_at] data after twenty
minutes.

To be honest, if I knew Ruby a little more I wouldn't be asking this
question, but exactly how does the addition and the subtraction of
Time work in Rails? Are they treated as time variables, or integer
variables of some form?

Would something like this work?

Hi --

I want to create a simple one-line function (to be used by a
before_filter) that expires the session[:updated_at] data after twenty
minutes.

To be honest, if I knew Ruby a little more I wouldn't be asking this
question, but exactly how does the addition and the subtraction of
Time work in Rails? Are they treated as time variables, or integer
variables of some form?

Would something like this work?
-----------------------------------
private
def expire_session
session[:updated_at]=nil if Time.now-session[:updated_at]<20.minutes

I think you want > rather than <.

end

You can always try these things in the application console (not
regular irb, because a lot of stuff like "minutes" requires
ActiveSupport [which you can load in irb, but it's easier to use the
Rails console]):

update = Time.now; until Time.now - update > 5.seconds;

?> puts "waiting..."; sleep 1; end; puts "done"
waiting...
done

I think there are plugins that do more fine-grained and featureful
observing for you, but anyway, that's the basic idea.

David

I think you want > rather than <.

> end

Whoops, yes you're right about that. Regardless, if Time.now-
session[:updated_at] works, than I really have nothing to worry about.