10
2007
Rails Flash Helpers
Rails allows for the posting of errors through use of flashes. Calling something like
flash[:notice] = “Login Successful”
in your controller will allow you to display it in your view by calling the following code in your view.
<%= flash[:notice] %>
The types of flashes you can use are not pre-defined so if you wanted to use
flash[:pearl_jam]
you could. That being said, there are some generally recognized types of flashes that folks are standardizing around. The most common flashes that I’ve seen are:
flash[:notice]
flash[:message]
flash[:warning]
flash[:error]
I found some code at http://www.bigbold.com/snippets/posts/show/2348 that helped me out. You can edit it to suit your own needs. All you need to do is put thes code in your application_helper.rb file. It will allow you to call
<%= display_standard_flashes %>
in any of your views to display all flash types. This code also adds CSS class definitions that match the flash name, which will allow you to define a different look for your different flash types.

An article by


[...] Rails Flash Helpers [...]