I'm on a twitter bootstrap binge at the moment, it fills my soul with glee to start a new project with a base template that looks better than the usual dog's breakfast. Anyway, there are days when you just need a piece of code to blast in to your templates so that you can get on with your work. This is one of those and slapping the tremendous bootstrap success, warning and info messages into our normal flash message stylings is just what the doctor ordered.
Here then, for your delectation, a small snippet of code to pop into your application layout in place of your usual flash message code that will style things up the bootstrap way. If you prefer, pull this out into a helper.....if you think that's the rails way. Personally, for small projects, I don't bother.
This file contains 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
<% flash.each do |name, msg| %> | |
<div class="alert alert-<%= name == :notice ? "success" : "error" %>"> | |
<a class="close" data-dismiss="alert">×</a> | |
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %> | |
</div> | |
<% end %> |
Comments
Post a Comment