On Thu, Sep 17, 2009 at 7:46 PM, TRBNGR <[email protected]> wrote:
>
> Ok, I tried searching for the answer to this but couldn't find a
> thread about it, so here goes...
>
> I'm using sessions that I am storing in the database, is there an
> accepted rails way of deleting out the old sessions?
>
> Unless I hear a better idea, I was going to write a simple class and
> call it from a cronjob to delete sessions that have been inactive
> after a specified period of time.
class ApplicationController < ActionController::Base
before_filter :clean
def clean
ActiveRecord::Base.connection.execute( "
DELETE FROM sessions
WHERE NOW() - updated_at > 3600
" ) if rand( 1000 ) % 10 == 0
end
end
--
Greg Donald
http://destiney.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---