Created
December 15, 2013 01:47
-
-
Save maxivak/7967703 to your computer and use it in GitHub Desktop.
Rails sessions: rake task to clear old sessions. Details: http://maxivak.com/rails-clear-old-sessions-stored-in-database/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :sessions do | |
desc "Clear expired sessions (more than 3 days old)" | |
task :cleanup => :environment do | |
sql = "DELETE FROM sessions WHERE (updated_at < '#{Date.today - 3.days}')" | |
ActiveRecord::Base.connection.execute(sql) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment