Platinum Partner

Standardizing Rails Flash Messages

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 %>
{{ tag }}, {{tag}},

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

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}