Sha256: 59edb1946bea5187ebfc92fe0ee13e7ef77922ea58a2ddf6c2f3a5a66a70f6cb

Contents?: true

Size: 779 Bytes

Versions: 6

Compression:

Stored size: 779 Bytes

Contents

module BootstrapFlashHelper
  ALERT_TYPES = [:error, :info, :success, :warning]

  def bootstrap_flash
    flash_messages = []
    flash.each do |type, message|
      # Skip empty messages, e.g. for devise messages set to nothing in a locale file.
      next if message.blank?
      
      type = :success if type == :notice
      type = :error   if type == :alert
      next unless ALERT_TYPES.include?(type)

      Array(message).each do |msg|
        text = content_tag(:div,
                           content_tag(:button, raw("×"), :class => "close", "data-dismiss" => "alert") +
                           msg.html_safe, :class => "alert fade in alert-#{type}")
        flash_messages << text if msg
      end
    end
    flash_messages.join("\n").html_safe
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
unknown_admin-0.1.5 app/helpers/bootstrap_flash_helper.rb
unknown_admin-0.1.4 app/helpers/bootstrap_flash_helper.rb
unknown_admin-0.1.3 app/helpers/bootstrap_flash_helper.rb
unknown_admin-0.1.2 app/helpers/bootstrap_flash_helper.rb
unknown_admin-0.1.1 app/helpers/bootstrap_flash_helper.rb
unknown_admin-0.1.0 app/helpers/bootstrap_flash_helper.rb