How to show flash message in Rails only once?

Is it possible to show a flash message in rails only once? I mean, when I delete something, the flash drive says “Deleted (undo)”, and then, if I click and then the “Back back” button, the message is still there.

+6
ruby-on-rails
source share
2 answers

This is probably a common browser caching issue. You can force your browser to reload the page by clicking the back button, setting some headers without a cache.

You can try this approach: (found after a quick search on Google, you might want to dig deeper)

http://blog.serendeputy.com/posts/how-to-prevent-browsers-from-caching-a-page-in-rails/

+1
source share

you can use

flash.now 

Here's the rule of thumb.

 In your controller, use flash when you're redirecting and flash.now when rendering. 
+15
source share

All Articles