Module: BootstrapFlashHelper
- Defined in:
- app/helpers/bootstrap_flash_helper.rb
Constant Summary collapse
- ALERT_TYPES_MAP =
{ notice: :success, alert: :danger, error: :danger, info: :info, warning: :warning }.freeze
Instance Method Summary collapse
Instance Method Details
#bootstrap_flash ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/helpers/bootstrap_flash_helper.rb', line 10 def bootstrap_flash safe_join(flash.each_with_object([]) do |(type, ), | next if .blank? || !.respond_to?(:to_str) type = ALERT_TYPES_MAP.fetch(type.to_sym, type) << flash_container(type, ) end, "\n").presence end |
#flash_container(type, message) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/bootstrap_flash_helper.rb', line 18 def flash_container(type, ) content_tag :div, class: "alert alert-#{type} alert-dismissable" do type: "button", class: "close", data: { dismiss: "alert" } do "×".html_safe end.safe_concat() end end |