Skip to content

Instantly share code, notes, and snippets.

@MartinHeimbring
Last active August 29, 2015 14:15
Show Gist options
  • Save MartinHeimbring/fff9b6da83dff1b9b29f to your computer and use it in GitHub Desktop.
Save MartinHeimbring/fff9b6da83dff1b9b29f to your computer and use it in GitHub Desktop.
Form error messages w/ bootstrap (from MIchael Hartl Tutorial)
<!-- _error_messages.html.erb -->
<% if @user.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@user.errors.count, "error") %>.
</div>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<!-- in _form.html.erb -->
<%= render 'layout/errors', object: @model_object %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment