Module: Bootstrap::FlashHelper

Defined in:
app/helpers/bootstrap/flash_helper.rb

Overview

Rails helpers for producing flash messages styled as Bootstrap alert boxes.

Examples:

# in a layout or view

flash_messages
flash_messages close: false
flash_messages class: 'flash', id: 'my-flash'

# override default mapping

Bootstrap::FlashHelper.mapping[:notice] = :success
Bootstrap::FlashHelper.mapping[:mistake] = :error

Constant Summary collapse

DEFAULT_MAPPING =
{
  :notice => :info,
  :alert => :error,
}

Instance Method Summary collapse

Instance Method Details

#flash_messages(options = {}) ⇒ String

Returns Bootstrap alerts for each entry in flash

Parameters:

  • options (Hash) (defaults to: {})

    unrecognized options are passed the the AlertHelper#alert method

Options Hash (options):

  • :close (Boolean)

    if false the close button is not shown

Returns:

  • (String)


29
30
31
32
# File 'app/helpers/bootstrap/flash_helper.rb', line 29

def flash_messages(options={})
  messages = flash.map { |type, message| _bs_flash_for(type, message, options) }
  safe_join(messages, "\n")
end