-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Flash returns the same message twice #196
Comments
@greggilbert Hi Greg, I'm sorry about this problem. Can you please try this for me? module Web::Controllers::Home
class Index
include Web::Action
include Hanami::Action::Session
before :clear_flash # new callback
expose :message
def call(params)
p "HI THERE -> #{flash[:message]}"
@message = flash[:message]
end
private
# new method
def clear_flash
flash.clear
end
end
end Do these new lines of code solve your problem? PS: I'm NOT advocating to keep these lines of code around forever, but just to try if this solution can work and eventually add it to the framework. 😉 |
@jodosha, no need to apologize - always glad to help. Yes, putting that change in place fixes it. |
@greggilbert Thanks for getting back. We'll write a patch for this. 👍 |
@greggilbert I'm trying to reproduce the error on my machine, but without success... Actually, the flash object is empty after the redirection, printing |
@matiasleidemer Sorry about the delay. I just did a fresh install of Hanami and got the same thing as before. Did you enable sessions for the app? I just put up a proof of concept. You should be able to just clone that, |
@greggilbert cool, I'll take a look later today, thanks! |
Hello, what is the desired behavior here? I'd say the flash message shouldn't be available after the refresh, right? Since, according to the documentation It has a life span of one HTTP request or redirect. I'm asking just to make sure 😬 |
@matiasleidemer Yeah, that's what I'd expect. |
@greggilbert cool, I was able to fix it here, I will open a PR later today :) |
#200 should take care of this, thanks for setting up a POC @greggilbert, it was really helpful... 😄 Since this is my first PR I'm not very sure I followed all the guidelines. Nevertheless, I'd be happy to address any other issue. |
Awesome. Thanks, all! |
I'm having a weird issue using flash with controller 0.8.1, where I get the same message twice. I'm POSTing to
save.rb
, saving the message there, and then catching the message inindex.rb
:On the first load of index, it prints out
"HI THERE -> Saved!"
On the second load, it prints out
"HI THERE -> {:message=>\"Saved!\"}"
Am I doing something wrong? Is this related to #195?
The text was updated successfully, but these errors were encountered: