Created
January 12, 2012 14:35
-
-
Save potomak/1600856 to your computer and use it in GitHub Desktop.
Rails flash messages using Twitter bootstrap
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
<% [:notice, :error, :alert].each do |level| %> | |
<% unless flash[level].blank? %> | |
<div class="alert-message <%= flash_class(level) %>"> | |
<a class="close" href="#">×</a> | |
<%= content_tag :p, flash[level] %> | |
</div> | |
<% end %> | |
<% end %> |
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
module ApplicationHelper | |
def flash_class(level) | |
case level | |
when :notice then "info" | |
when :error then "error" | |
when :alert then "warning" | |
end | |
end | |
end |
I had an error also found here: http://stackoverflow.com/questions/7972084/rails-flashnotice-always-nil.
I don't think you can name your partial "_flash.html.erb". It needs to be named something else. Otherwise, thanks! Works great!
Thanks a lot...works fine.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The class is just called
alert
(as opposed toalert-message
) in Bootstrap 2.