What's the correct way to set a flash message for the current view but not show it for the next request. In other words usually you set the flash message and redirect and the flash message gets shown on the redirect. I don't want to redirect and so I need to make sure the flash message doesn't get shown twice.
Asked
Active
Viewed 6,517 times
38
-
make sure that you put your flash massage in any action you want to display, not in application layout – Someth Victory Jun 20 '12 at 08:10
-
Check out http://stackoverflow.com/a/4614017/246263 for more information – Veger Jun 20 '12 at 08:13
2 Answers
24
if you are to 'render' the page, use flash.now[:notice]
, when you want to 'redirect', use flash[:notice]

Marcus
- 6,701
- 4
- 19
- 28
-
1This is the correct way to use .now and should be voted as the correct answer. – moeabdol Jan 25 '16 at 19:48