Reputation: 38832
I'm storing the Rails Sessions in database using Active Record Store. At some point I want to replace the actual Rails Session for another one extracted from the database.
Let's say the Session to restore ID comes in the param session_id
.
How can I retrieve the Session to restore and replace the actual session?
Upvotes: 0
Views: 584
Reputation: 38832
The simplest way I found to do it is in a before_filter
def restore_session
return if params[:session_id].blank?
restored_session = ActiveRecord::SessionStore::Session.find_by_session_id(params[:session_id])
if restored_session
session.update(restored_session.data)
restored_session.destroy
end
end
Upvotes: 1