Skip to content

Instantly share code, notes, and snippets.

@BideoWego
Last active February 15, 2016 05:54
Show Gist options
  • Save BideoWego/9e8b6626fdcb77267377 to your computer and use it in GitHub Desktop.
Save BideoWego/9e8b6626fdcb77267377 to your computer and use it in GitHub Desktop.
Rails flash partial with Bootstrap classes
<% unless flash.empty? %>
<% flash.each do |key, value| %>
<div class="main-flash alert alert-<%= flash_css_class(key) %> text-center" style="border-radius: 0;">
<%= value %>
</div>
<% end %>
<% end %>
module ApplicationHelper
def flash_css_class(key)
if ['notice', 'error'].include?(key)
key == 'notice' ? 'info' : 'danger'
else
key.to_s
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment