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.
Wes G. (Guest)
on 2006-04-18 03: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
Trevor S. (Guest)
on 2006-04-18 03: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 S.
http://somethinglearned.com
Wes G. (Guest)
on 2006-04-18 03:42
Trevor,

You the man.

WG
Trevor S. 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 S.
> http://somethinglearned.com
This topic is locked and can not be replied to.