The flash
hash is basically a variable which is populated with each controller/action
request, and then is reset after the request has been performed. As Adilbiy Kanzitdinov
has mentioned - it's set in the session
hash :
The flash provides a way to pass temporary objects between actions.
Anything you place in the flash will be exposed to the very next
action and then cleared out. This is a great way of doing notices and
alerts, such as a create action that sets flash[:notice] = "Post
successfully created" before redirecting to a display action that can
then expose the flash to its template. Actually, that exposure is
automatically done.
You need to remember that ROR is full-stack, meaning it has a bunch of middleware it uses to create the most efficient responses for your users. This allows you to set local
variables (session
, params
, flash
are 3 I can think of)
To call from a view, you just need to reference this local variable, as below:
<%= flash[:key] %>