Skip to content

Instantly share code, notes, and snippets.

@djbender
Forked from potomak/_flash.html.erb
Last active December 16, 2015 22:09
Show Gist options
  • Save djbender/5504996 to your computer and use it in GitHub Desktop.
Save djbender/5504996 to your computer and use it in GitHub Desktop.
Using this in Rails v4.0.0.rc1 and Bootstrap v2.3.1
<% [:notice, :error, :alert, :success].each do |level| %>
<% unless flash[level].blank? %>
<div class="alert alert-<%= flash_class(level) %>">
<a class="close" href="#">×</a>
<%= content_tag :p, flash[level] %>
</div>
<% end %>
<% end %>
module ApplicationHelper
def flash_class(level)
case level
when :notice then "info" #blue
when :error then "error" #red
when :alert then "warning" #yellow
when :success then "success" #green
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment