chourobin
10/25/2012 - 12:05 AM

Rails flash messages using Twitter bootstrap

Rails flash messages using Twitter bootstrap

module ApplicationHelper
  def flash_class(level)
    case level
    when :notice then "info"
    when :error then "error"
    when :alert then "warning"
    end
  end
end
<% [:notice, :error, :alert].each do |level| %>
  <% unless flash[level].blank? %>
    <div class="alert <%= flash_class(level) %>">
      <a class="close" href="#">×</a>
      <%= content_tag :p, flash[level] %>
    </div>
  <% end %>
<% end %>