Skip to content

Instantly share code, notes, and snippets.

@forced-request
Created March 25, 2014 21:58
Show Gist options
  • Save forced-request/9772342 to your computer and use it in GitHub Desktop.
Save forced-request/9772342 to your computer and use it in GitHub Desktop.
module BootstrapFlashHelperPatched
ALERT_TYPES = [:error, :info, :success, :warning] unless const_defined?(:ALERT_TYPES)
def bootstrap_flash_patched
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 = type.to_sym
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, :class => "alert fade in alert-#{type}")
flash_messages << text if msg
end
end
flash_messages.join("\n").html_safe
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment