Skip to content

Instantly share code, notes, and snippets.

@jsborjesson
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save jsborjesson/9100484 to your computer and use it in GitHub Desktop.

Select an option

Save jsborjesson/9100484 to your computer and use it in GitHub Desktop.
Bootstrap 3 flashes in Rails
<% flash.each do |type, message| %>
<div class="<%= bootstrap_flash_class type %>"><%= message %></div>
<% end %>
<%# render the flashes %>
<%= render partial: 'shared/flashes' %>
module ApplicationHelper
def bootstrap_flash_class(flash_type)
map = {
notice: 'info',
success: 'success',
error: 'danger',
alert: 'warning'
}
"alert alert-#{map[flash_type.to_sym]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment