Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Standardizing Rails Flash Messages

DZone's Guide to

Standardizing Rails Flash Messages

·
Free Resource
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] %>
    <%= "
  
#{flash[name]}
" %> <% end %> <% end %>
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}