title: Rails Merge child errors with Parent errors
body: <p>I've got the following two (sanitized/stylized) models:</p>
  
  <pre><code> class DrivingExam &lt; ActiveRecord::Base
     belongs_to :dmv_rules
     has_many :invigilator_assignments, as: :assignable
     has_many :invigilator, through: :invigilator_assignments
  
     validate do |record|
       record.invigilator_assignments.each do |i|
         next if i.valid?
         i.errors.full_messages.each do |msg|
           errors.add_to_base(msg)
         end
       end
     end
   end
  
  
  
   class InvigilatorAssignment  &lt; ActiveRecord::Base
     attr_accessible :invigilator_id
  
     belongs_to :assignable, polymorphic: true
     belongs_to :invigilator
  
     validates :invigilator_id, presence: true
  
     validates_each :invigilator do |record, attr, value|
       if record.assignable.is_a?(DrivingExam) &amp;&amp; !value.no_scheduling_conflicts?
         record.errors.add attr, "This Invigilator has a scheduling conflict"
       end
  
     end
   end
  </code></pre>
  
  <p>These get called from the <code>DrivingExamController</code> by way of:</p>
  
  <pre><code> if @driving_exam.save
  </code></pre>
  
  <p>The expected behaviour is that the model should return false on the validation and join the child messages into the parent errors hash and pass this up to the controller.</p>
  
  <p>What happens instead is that the page fails to save (this is good) with a 422(this is weird) and does not pass the messages.</p>
  
  <p>By adding <code>puts</code> statements throughout the above code, I have established that:</p>
  
  <p>1) The if condition within <code>validates_each</code> is successful, and the <code>record.errors</code> array is thus set inside the <code>InvigilatorAssignment</code> model.</p>
  
  <p>2) In the <code>validate do</code> loop the invigilator assignment is valid and has no errors</p>
  
  <p>3) the <code>validate do</code> loop runs before the <code>validates_each</code> loop</p>
  
  <p>So the question is: How do I ensure that the <code>DrivingExam</code> validates <code>InvigilatorAssignment</code> and merges its error messages onto its own error hash.</p>