38

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.

Simone
  • 20,302
  • 14
  • 79
  • 103
pguardiario
  • 53,827
  • 19
  • 119
  • 159

2 Answers2

71
flash.now[:notice] = 'message'
Fabio
  • 18,856
  • 9
  • 82
  • 114
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