Created
March 16, 2011 19:58
-
-
Save alassek/873195 to your computer and use it in GitHub Desktop.
Get a flash message from a Rails Controller in a Sinatra action
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
| def get_flash | |
| signed_message = request.cookies['_project_name_session'] | |
| if signed_message.present? | |
| secret = ProjectName::Application.config.secret_token | |
| verifier = ActiveSupport::MessageVerifier.new(secret) | |
| session = verifier.verify(signed_message) | |
| @flash = session.delete('flash') | |
| signed_message = verifier.generate(session) | |
| response.set_cookie('_project_name_session', :value => signed_message, :path => '/') | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure you're setting the path in
response#set_cookieor you will have a very strange session bug.