Module: BootstrapFlashHelper

Defined in:
app/helpers/bootstrap_flash_helper.rb

Constant Summary collapse

AVALIABLE_TYPES =
%w(info success warning danger).freeze

Instance Method Summary collapse

Instance Method Details

#bootstrap_flashObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/bootstrap_flash_helper.rb', line 3

def bootstrap_flash
   flash_messages = []
   flash.each do |type, message|
     # Skip Devise :timeout and :timedout flags
     type_to_s = type.to_s
     next if type_to_s == 'timeout' || type_to_s == 'timedout'
     type_to_s = 'error' if type_to_s == 'danger'
     use_type = AVALIABLE_TYPES.include?(type_to_s) ? type_to_s : :info
     text = (:div,
                        (:button, raw('×'), :class => 'close', 'data-dismiss' => 'alert') +
                        message, class: "alert fade in alert-#{use_type}")
     flash_messages << text if message
   end
   flash_messages.join("\n").html_safe
end