Skip to content

Instantly share code, notes, and snippets.

@heycarsten
Created July 1, 2009 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heycarsten/138958 to your computer and use it in GitHub Desktop.
Save heycarsten/138958 to your computer and use it in GitHub Desktop.
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