Skip to content

Instantly share code, notes, and snippets.

@orafaelfragoso
Created August 9, 2014 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orafaelfragoso/db39aadf0b923ff61182 to your computer and use it in GitHub Desktop.
Save orafaelfragoso/db39aadf0b923ff61182 to your computer and use it in GitHub Desktop.
Alert message helpers for Rails
<% flash.each do |type, message| %>
<div class="alert <%= alert_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
module ApplicationHelper
def alert_class_for(flash_type)
{
:success => 'alert-success',
:error => 'alert-danger',
:alert => 'alert-warning',
:notice => 'alert-info'
}[flash_type.to_sym] || flash_type.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment