Skip to content

Instantly share code, notes, and snippets.

@dcorking
Created February 10, 2016 12:14
Show Gist options
  • Save dcorking/821d61466a4729177b0a to your computer and use it in GitHub Desktop.
Save dcorking/821d61466a4729177b0a to your computer and use it in GitHub Desktop.
Translate Rails flash key to metronic theme alert class
<% # Metronic theme alert classes can be used to style Rails 4 flash messages, for example like this. Render this partial from a page layout or page body. %>
<% if flash.any? %>
<div class="alerts">
<% user_facing_flashes.each do |key, value| -%>
<% # translate flash key to metronic alert class %>
<% # http://www.keenthemes.com/preview/metronic/theme/admin_1/ui_alerts_api.html %>
<% alert_class = {'alert' => 'alert-warning', 'notice' => 'alert-info'}[key] %>
<div class="alert <%= alert_class %>"><%= value %></div>
<% end -%>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment