“Flash” is a ruby-on-rails-based agreement for storing information generated in a single request (for example, “invalid username” or “session not found” or “thank you for purchasing from us” or “updating the cart”) temporarily to display in the next view from the client.
A flash is a hash-like object.
The .map method for hash-like objects will iterate over all hash elements; in this case, a block is passed to the .map method that takes two parameters (which it calls key and value , because key can be used to search for value from the hash). The block uses the content_tag helper to output new <div> elements with a value from the hash and CSS key selector class.
So, for such a flash: {:name => "sars", :food => "pizza"}
It will output HTML something like this: <div class="name">sars</div><div class="food">pizza</div> .
This is a smart helper method that probably preserves a fair bit of input, but it makes some assumptions: the order in the view doesn't matter, all keys are either in CSS already, or CSS is ready to handle unknown class elements in an elegant way. This helper can be used only once in a template, but it would still be useful to use it as a method that could later be added to other projects.
source share