Skip to content

Instantly share code, notes, and snippets.

@hfm
Last active December 17, 2015 22:48
Show Gist options
  • Select an option

  • Save hfm/5684101 to your computer and use it in GitHub Desktop.

Select an option

Save hfm/5684101 to your computer and use it in GitHub Desktop.
Rails Tutorial Chap 7 memo.
# Listing 7.24. A partial for displaying form submission error messages.
- <% if @user.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
The form contains <%= pluralize(@user.errors.count, "error") %>.
</div>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li>
<% end %>
</ul>
</div>
- <% end %>
# Listing 7.23. Code to display error messages on the signup form.
<% provide(:title, 'Sign up') %>
<h1>Sign up</h1>
<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
- <%= render 'shared/error_messages' %>
+ <%= render 'shared/error_messages' if @user.errors.any? %>
.
.
.
<% end %>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment