Skip to content

Instantly share code, notes, and snippets.

@visdesarrollo2
Forked from suryart/application.html.erb
Last active August 29, 2015 14:14
Show Gist options
  • Save visdesarrollo2/a42685a9f70a02acff9c to your computer and use it in GitHub Desktop.
Save visdesarrollo2/a42685a9f70a02acff9c to your computer and use it in GitHub Desktop.
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
module ApplicationHelper
def bootstrap_class_for flash_type
case flash_type
when :success
"alert-success"
when :error
"alert-error"
when :alert
"alert-warning"
when :notice
"alert-info"
else
flash_type.to_s
end
end
def flash_messages(opts = {})
flash.each do |msg_type, message|
concat(content_tag(:div, message, class: "alert #{bootstrap_class_for(msg_type)} fade in") do
concat content_tag(:button, 'x', class: "close", data: { dismiss: 'alert' })
concat message
end)
end
nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment