Flash Message Conductor
A simple pattern for managing flash messages in your Ruby on Rails application.
Installation
Gem
In environment.rb;
gem 'glennr-flash-message-conductor'
config.gem 'glennr-flash-message-conductor', :lib => 'flash-message-conductor', :source => 'http://gemcutter.org', :version => ">=1.1"
Plugin
script/plugin install git://github.com/glennr/flash-message-conductor.git
Example
Redirect actions
add_info( 'foo' )
redirect_to :action => "show"
is the equivalent of
flash[:info] = 'foo'
Render actions
add_info_now( 'foo' )
render :action => "show"
is the equivalent of
flash[:info] = 'foo'
Controller helpers included:
add_success( )
add_info( )
add_warning( )
add_error( )
( ) # alias for add_success
add_notice( ) #alias for add_info
Plus all the _now methods e.g.
add_success_now( )
View helpers
<%= render_flash_messages %>
produces:
<div id="flash_messages">
<div class="info">You have successfully done XYZ...</p>
</div>
or… if you set an error
<div id="flash_messages">
<p class="error">Oops! Something went bonkers!</p>
</div>
Example CSS and Icons
See examples/
Copyright © 2008 Planet Argon, released under the MIT license