Skip to content

Instantly share code, notes, and snippets.

@denwwer
Last active December 31, 2015 13:18
Show Gist options
  • Save denwwer/7991651 to your computer and use it in GitHub Desktop.
Save denwwer/7991651 to your computer and use it in GitHub Desktop.
example how restore session in Rails 3
## 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