heycarsten (owner)

Revisions

gist: 138958 Download_button fork
public
Public Clone URL: git://gist.github.com/138958.git
Embed All Files: show embed
flash_helper.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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