Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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