Skip to content

Instantly share code, notes, and snippets.

@dacur
Created February 28, 2015 16:23
Show Gist options
  • Save dacur/0ca87f83184beeda89c8 to your computer and use it in GitHub Desktop.
Save dacur/0ca87f83184beeda89c8 to your computer and use it in GitHub Desktop.
This is a sample application.html.erb file that adds bootstrap styling to devise alerts. It uses green and red coloring, and adds an 'x' button so that the messages can be dismissed.
<!DOCTYPE html>
<html>
<head>
<title>YOUR TITLE HERE</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= render 'layouts/header' %>
<div class="container">
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div class="alert alert-<%= name.to_s == 'notice' ? "success" : "danger" %> alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
</div>
<% end %>
<% end %>
<%= yield %>
<%= render 'layouts/footer' %>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment