How would I clear all rails sessions?
In Rails 4, the accepted answer (rake db:sessions:clear
) no longer works because ActiveRecord::SessionStore was extracted into the active_record-session_store
gem. (See here for further explanation)
You can now either install the active_record-session_store
gem and use rake db:sessions:clear
as in Rails 3, or create a custom Rake task that looks like so:
namespace :db do namespace :sessions do desc "Clear ActiveRecord sessions" task :clear => :environment do sql = 'TRUNCATE sessions;' ActiveRecord::Base.connection.execute(sql) end endend