Created
July 1, 2009 18:29
-
-
Save heycarsten/138958 to your computer and use it in GitHub Desktop.
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
module FlashHelper | |
# Will output all flashes in the FlashHash into DIV elements containing the | |
# FlashHash value as content and the FlashHash key as the class name. Some | |
# class names which have styles associated with them are: | |
# * information / info | |
# * success | |
# * warning | |
# * error | |
def flash_messages | |
return if flash.empty? | |
a = [] | |
a << flash.inject('') { |t,(k,v)| t << flash_message(k, v) } | |
a << tag(:hr, :class => 'hide') | |
content_tag :div, :id => 'header_flash_messages', :class => 'clear' do | |
a.join("\n") | |
end | |
end | |
# Renders a single flash message. | |
def flash_message(type, message) | |
render :partial => '/layouts/partials/flash_message', :locals => { | |
:type => type.to_s, | |
:message => message } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment