views:

19

answers:

1

I find it odd that rails doesn't have a standard way of clearing out old sessions (file, ActiveRecord, or otherwise). There's a rake task that deletes all of them, which is not what I need (need to only delete sessions older than X weeks).

I can write a 3-line script and run it periodically easily enough, but wanted to first check if there is a best practice that I'm missing out on.

A: 

I found this on Amateur geek, although this may be what you were referring to above:

class SessionCleaner
  def self.remove_stale_sessions
    CGI::Session::ActiveRecordStore::Session.
      destroy_all( ['updated_at <?', 1.hour.ago] ) 
  end
end
jessecurry