Skip to content

Instantly share code, notes, and snippets.

@kenzie
Created September 13, 2011 12:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenzie/1213729 to your computer and use it in GitHub Desktop.
Save kenzie/1213729 to your computer and use it in GitHub Desktop.
Rails 3 form error partial
<% if target.errors.any? %>
<div class="error_explanation">
<h2><%= pluralize(target.errors.count, "error") %> prevented this record from being saved:</h2>
<ul>
<% target.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form_for @user, :url => user_path do |f| %>
<%= render "shared/error_messages", :target => @user %>
<p>
<%= f.label :email %>
<%= f.text_field :email %>
</p>
<p>
<%= f.label :password %>
<%= f.password_field :password %>
</p>
<p class="actions"><%= f.submit %></p>
<% end %>
@sairam49
Copy link

sairam49 commented Apr 5, 2016

awesome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment