Last active
December 31, 2015 13:18
-
-
Save denwwer/7991651 to your computer and use it in GitHub Desktop.
example how restore session in Rails 3
This file contains 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
## in controller | |
# skip verify_authenticity_token when data from another server | |
skip_before_filter :verify_authenticity_token, :only => [:restore] | |
def restore | |
restore_session_from(params[:session_id]) | |
redirect_to '/' | |
end | |
## ApplicationController | |
def restore_session_from(session_id) | |
restored_session = Session.find_by_session_id(session_id) | |
if restored_session | |
session.update(restored_session.data) | |
restored_session.destroy | |
else | |
Rails.logger.error("Can't find session_id #{session_id} for restore session.") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment