Skip to content

Instantly share code, notes, and snippets.

@rsl
Forked from anonymous/gist:9549170
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsl/9549203 to your computer and use it in GitHub Desktop.
Save rsl/9549203 to your computer and use it in GitHub Desktop.
def insert_flash
content_tag :div, class: 'flash' do
flash.each do |name, msg|
add_flash name, msg
end
end
end
private
def add_flash(name, msg)
return unless msg.is_a?(String)
concat( content_tag( :div, class: "fade in alert alert-#{ flash_type_to_bootstrap(name) }") do
# This would be a candidate for a method as well...
concat( button_tag( "×".html_safe, class: "close", "aria-hidden" => true, "data-dismiss" => "alert" ) )
concat( content_tag :div, msg, :id => "flash_#{name}" )
end )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment