title: Rails3: Nested model - child validates_with method results in "NameError - uninitialized constant [parent]::[child]"
body: <p>Consider the following parent/child relationship where Parent is 1..n with Kids (only the relevant stuff here)...</p>
  
  <pre><code> class Parent &lt; ActiveRecord::Base
  
     # !EDIT! - was missing this require originally -- was the root cause!
     require "Kid"
  
     has_many :kids, :dependent =&gt; :destroy, :validate =&gt; true
     accepts_nested_attributes_for :kids
  
     validates_associated :kids
  
   end
  
   class Kid &lt; ActiveRecord::Base
  
     belongs_to :parent
  
     # for simplicity, assume a single field:  @item
     validates_presence_of :item, :message =&gt; "is expected"
  
   end
  </code></pre>
  
  <p>The validates_presence_of methods on the Kid model works as expected on validation failure, generating a final string of <code>Item is expected</code> per the custom message attribute supplied.</p>
  
  <p>But if  try <code>validates_with</code>, instead...</p>
  
  <pre><code> class Kid &lt; ActiveRecord::Base
  
     belongs_to :parent
  
     validates_with TrivialValidator
  
   end
  
   class TrivialValidator
  
     def validate
        if record.item != "good"
          record.errors[:base] &lt;&lt; "Bad item!"
        end
     end
  
   end
  </code></pre>
  
  <p>...Rails returns a <code>NameError - uninitialized constant Parent::Kid</code> error following not only an attempt to create (initial persist) user data, but also when even attempting to build the initial form.  Relevant bits from the controller:</p>
  
  <pre><code>def new
   @parent = Parent.new
   @parent.kids.new # NameError, validates_* methods called within
  end
  
  def create
   @parent = Parent.new(params[:parent])
   @parent.save # NameError, validates_* methods called within
  end
  </code></pre>
  
  <p>The error suggests that somewhere during model name (and perhaps field name?) resolution for error message construction, something has run afoul. But why would it happen for some <code>validates_*</code> methods and not others?</p>
  
  <p>Anybody else hit a wall with this?  Is there some ceremony needed here that I've left out in order to make this work, particularly regarding model names?</p>