Skip to content

Instantly share code, notes, and snippets.

@brentvatne
Created April 2, 2011 02:11
Show Gist options
  • Save brentvatne/899167 to your computer and use it in GitHub Desktop.
Save brentvatne/899167 to your computer and use it in GitHub Desktop.
error messages partial not accepting locals argument?
#this is the view for Users#new
<h1>Sign up</h1>
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
<%= render 'fields', :f => f %>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
#this is the error partial in shared/error_messages
<% if object.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(object.errors.count, "error") %>
prohibited this <%= object.class.to_s %> from being saved:
</h2>
<p>There were problems with the following fields:</p>
<ul>
<% object.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</div>
<% end %>
undefined local variable or method `object' for #<#<Class:0x00000102067fe0>:0x0000010205c8c0>
Extracted source (around line #1):
1: <% if object.errors.any? %>
2: <div id="error_explanation">
3: <h2>
4: <%= pluralize(object.errors.count, "error") %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment