Skip to content

Instantly share code, notes, and snippets.

@OsamaShabrez
Created January 19, 2015 11:14
Show Gist options
  • Save OsamaShabrez/9b98a4df6e91580af44c to your computer and use it in GitHub Desktop.
Save OsamaShabrez/9b98a4df6e91580af44c to your computer and use it in GitHub Desktop.
Rails flash message using Twitter Bootstrap 3
<% flash.each do |type, message| %>
<div class="alert <%= alert_class_for(type) %> alert-dismissable fade in">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<%= message %>
</div>
<% end %>
<%= render partial: "shared/flash_messages", flash: flash %>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment