Created
February 10, 2016 12:14
-
-
Save dcorking/821d61466a4729177b0a to your computer and use it in GitHub Desktop.
Translate Rails flash key to metronic theme alert class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% # 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