This extension provides a simple way to handle flash messages. You can easily display notices, errors and warnings using the convinience method.


Edit your Gemfile and add:

gem "flash_helper"

then run bundler:

bundle install


For example, in your layout use :


Then in your controllers you can use :

flash[:notice] = "Successfully created..."
flash[:errors] = "Creation failed!"
flash[:alert] = @news.errors
flash[:warning] = "The new user has no blog associated..."

Notice that "errors" and "alert" act the same way, they are just aliases due to old Rails convention where default convention key was "errors" and not "alert".

To translate default messages, in config/locales/fr.yml you can add :

  default_message: "Il y a des problèmes dans le formulaire :"

Tune display_flashes :

Options for flash helpers are optional and get their default values from the Bounga::FlashHelper::ViewHelpers.flash_options hash. You can write to this hash to override default options on the global level:

Bounga::FlashHelper::ViewHelpers.flash_options[:notice_class] = 'my_notice'

Available options (and their defaults) are :

:list_class       => 'errors_list'
:notice_class     => 'notice'
:errors_class     => 'errors'
:warning_class    => 'warning'
:default_message  => 'There are problems in your submission:'

By putting this into "config/initializers/flash_helper.rb" (or simply environment.rb in older versions of Rails) you can easily override any default option.


More information on Project homepage

Problems, comments, and suggestions are welcome on the ticket system

Copyright (c) 2012 Nicolas Cavigneaux, released under the MIT license