Forum: Ruby on Rails Understanding when flash gets reset (render vs. redirect_to)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-04-18 01:20
All,

I have a controller action that will do a different "render (:action)"
call
depending on whether or not data is valid.

When the data is invalid - I set a flash element to hold a message.

However, when I post back to this controller action and have valid data,
I still have the flash element set, which I don't want.

I believe this is because I did a render from the initial controller
call.

Do I need to use flash.now in this case because I haven't really
generated a new controller instance?

Thanks,
Wes
27c170f482104299af279902be0a9c26?d=identicon&s=25 Trevor Squires (Guest)
on 2006-04-18 01:41
(Received via mailing list)
Hey,

flash.now[:wibble] = "visible as flash[:wibble] in *this* request"
flash[:wibble] = "visible as flash[:wibble] in the *next* request"

HTH,
Trevor
--
Trevor Squires
http://somethinglearned.com
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2006-04-18 01:42
Trevor,

You the man.

WG
Trevor Squires wrote:
> Hey,
>
> flash.now[:wibble] = "visible as flash[:wibble] in *this* request"
> flash[:wibble] = "visible as flash[:wibble] in the *next* request"
>
> HTH,
> Trevor
> --
> Trevor Squires
> http://somethinglearned.com
This topic is locked and can not be replied to.