Sha256: 56c50a9d12545c6775d99363405bf98c5940e0d915473191820469559b1f391c

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

require 'action_view/helpers'

module FoundationRailsHelper
  module FlashHelper
    # <div class="alert-box [success alert secondary]">
    #   This is an alert box.
    #   <a href="" class="close">&times;</a>
    # </div>
    DEFAULT_KEY_MATCHING = {
      :alert     => :alert,
      :notice    => :success,
      :info      => :info,
      :secondary => :secondary,
      :success   => :success,
      :error     => :alert,
      :warning   => :warning
    }
    def display_flash_messages(key_matching = {})
      key_matching = DEFAULT_KEY_MATCHING.merge(key_matching)

      flash.inject "" do |message, (key, value)|
        message += content_tag :div, :data => { :alert => "" }, :class => "alert-box #{key_matching[key.to_sym] || :standard}" do
          (value + link_to("&times;".html_safe, "#", :class => :close)).html_safe
        end
      end.html_safe
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foundation_rails_helper-1.0.0 lib/foundation_rails_helper/flash_helper.rb