Hello,
I have a Rails 3 beta 4 where flash messages are not cleared when they should be. Please note that on a freshly created Rails 3 beta 4 application I do not face the problem. I searched for something flash specific in my application that could cause the problem, but I found nothing.
In the home page controller action I set flash.now.notice = "hello". This flash message is correctly displayed on the home page.
But when I request another page, the flash message is still displayed although I do not set a flash message in this other page controller action.
In my application controller, I log the content of the session['flash'] object in a before filter and in an after filter. Here is what I get:
1. request on the homepage setting the flash message: - before filter: session['flash'] = nil - after filter : session['flash'] = {:notice=>"hello"}
2. request on another page not setting the flash message: - before filter: session['flash'] = {"notice"=>"hello"} - after filter : session['flash'] = {"notice"=>"hello"}
I don't understand why the session['flash'] contains {"notice" => "hello"} at the beginning of the request of the second page. The :notice key has correctly disappeared but a new key "notice" has appeared. That's what provokes the unwanted display of the flash message on the second request.
I've looked into the ActionDispatch::Flash class and tried to log what happened in the sweep function rails/flash.rb at main · rails/rails · GitHub The problem is that the key "notice" is not deleted as @used set contains :notice where the flash keys contains "notice".
I could not figure out how and where in the code the flash object is reconstructed from the cookie session. Also, is it possible from the browser to read the content of the Rails cookie session to directly see how is the flash stored in the cookie?
Any help or indication to further dig in my problem would be greatly
appreciated
Florent