Skip to content

Instantly share code, notes, and snippets.

@achmiral
Forked from SunDi3yansyah/application.html.erb
Created November 9, 2018 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save achmiral/ee22a6401dbdd3e3df5f88c3eef48475 to your computer and use it in GitHub Desktop.
Save achmiral/ee22a6401dbdd3e3df5f88c3eef48475 to your computer and use it in GitHub Desktop.
Each :notice :error :alert helper
<% [:notice, :error, :alert].each do |level| %>
<% unless flash[level].blank? %>
<div data-alert="alert" class="alert alert-<%= flash_class(level) %> fade in">
<a class="close" data-dismiss="alert" href="#">&times;</a>
<%= content_tag :p, flash[level] %>
</div>
<% end %>
<% end %>
module ApplicationHelper
def flash_class(level)
case level
when :notice then 'info'
when :error then 'error'
when :alert then 'warning'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment