-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be careful when using the 'shotgun' gem #7
Comments
"Hopefully this saves someone else a lot of time!" Yes, saved me! |
You saved me whatever I was about to spend after an evening and a morning of wondering what on Earth was happening to my brain. Thank you! |
😆 I can't believe I felt into this. Thanks for letting the issue open so dumb guys like me can appreciate your remark. |
Does anyone know why this is happening? It's not obvious to me that merely reloading the app on each request should cause this problem. The flash content is stored in a session cookie, which will be sent back to the app on the next request. The fact that the app was reloaded in between requests should not break anything. |
I think that, because shotgun reloads the entire app (does it spawn a new one? I'm not sure), the cookies on the server side are lost since it's the one that issues those cookies in the first place; at least, regarding flash messaging. Only when the HTTP response is returned, the cookie is stored. Because the process is interrupted in each request, redirection and message passing fail. |
Thank you for this. I was going a little crazy wondering why the |
Here's workaround that worked for me. Just add |
For anyone else who made this oversight while using Shotgun, be warned that sinatra-flash appears as though it isn't working, but really it is.
I'm assuming this is because Shotgun reloads the entire Sinatra app on each request, so sessions weren't working as they would normally.
So don't use shotgun while testing, use webbrick/unicorn/any other server.
Hopefully this saves someone else a lot of time!
P.S Maybe worth mentioning in the README somewhere?
The text was updated successfully, but these errors were encountered: