Module: FlashMessageHelper

Defined in:
app/helpers/flash_message_helper.rb

Instance Method Summary collapse

Instance Method Details

#flash_message(key, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/flash_message_helper.rb', line 10

def flash_message(key, options={})
  message = flash[key].to_s
  klass = "alert-#{key}"
  klass = "alert-success" if key.to_s == "notice"
  klass = nil if key.to_s == "alert"
  options.reverse_merge!(:class => "alert #{klass}", :id => "flash_#{key}")
  options.merge!(:style => "display:none;") if message.empty?
  message = '<button type="button" class="close" data-dismiss="alert">&times;</button>'.html_safe + h(message)
   :div, message, options
end

#flash_messages(*args) ⇒ Object



4
5
6
7
# File 'app/helpers/flash_message_helper.rb', line 4

def flash_messages(*args)
  options = args.extract_options!
  args.inject("") {|html, key| html << flash_message(key, options.dup)}.html_safe
end