This project is archived and is in readonly mode.
flash loses messages on redirect
-
José Valim
- State changed from new to invalid
As far as I know, this is the expected behavior. Flash messages are supposed to be shown in the next request. If you have double redirects, you are responsible for keeping them.
-
Greg Hazel
Well, isn't it a bug then that they are not kept if you do not touch the "flash" accessor method?
class ThingController < ApplicationController def login flash[:info] = "Welcome back!" # for this example previous_location will be good_times, but it could be any path on the site redirect_to current_user.previous_location end def good_times redirect_to :action => :homepage end def homepage # XXX: observe the "Welcome back!" message is present. logger.warn flash.inspect #=> {:info=>"Welcome back!"} end endPersonally though, the semantics of the flash hash discarding unused data are not useful. Display once-and-only-once semantics would be much better / less surprising.
-
Greg Hazel
Indication that the interface is a bit more cumbersome than people expect: http://www.rubysavedmylife.com/2007/12/15/flashnotice-vs-flashnowno...