Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

standardizing rails flash messages (See related posts)

a proposal from Luke Randall on the rails mailing list

:notice for positive feedback (action successful, etc)
:message for neutral feedback (reminders, etc)
:warning for negative feedback (action unsuccessful, error encountered, etc)


Then, in your controller or view you could place code such as the following:

FLASH_NAMES = [:notice, :warning, :message]

<% for name in FLASH_NAMES %>
  <% if flash[name] %>
    <%= "<div id=\"#{name}\">#{flash[name]}</div>" %>
  <% end %>
<% end %>

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts