Rails flash
Flash vs Flash.now
Flash
- flash persist across redirects
flash
: redirection, for the next request- Flash[:notice]’s message will persist to the next action and should be used when redirecting to another action via the ‘redirect_to’ method.
Flash.now
- flash.now doesn’t persist across redirects
flash.now
: render template only, for the same request- Flash.now[:notice]’s message will be displayed in the view your are rendering via the ‘render’ method.
Flash.clear
In rails we have the method flash.clear
to clear all flash messages.