3

When I use rails' redirect_to method in a controller and pass it a notice message, everything works great. The notice is shown at the top for the page redirected to and then disappears when the next page is visited.

However, if I instead set a flash message and then simply render a page, then the flash message is shown, but it's also shown on the next page visited:

flash[:alert] = 'Please fix mistakes outlined in red'
render action: 'show'

How do I not make the alert message show on the next page that's visited. I only want that alert message shown on this page being rendered.

Using Rails 3.2.8

at.
  • 50,922
  • 104
  • 292
  • 461
  • Also asked in [this question](http://stackoverflow.com/questions/4613952/why-flash-message-wont-disappear) and [this question](http://stackoverflow.com/questions/1017210/rails-flash-message-remains-for-two-page-loads). – Teemu Leisti May 31 '13 at 15:39

1 Answers1

8

Use now method:

flash.now[:alert] = 'Please fix mistakes outlined in red'
jdoe
  • 15,665
  • 2
  • 46
  • 48