title: Rails 3 - Error Validation on nested resource
body: <p>I'm really struggling with how to handle Error Handling in Rails 3.  I have hacked some ideas that could work but would rather do it the proper way.  If anyone can help or give guidance I would appreciate it.  Here is what I have so far</p>
  
  <p>ItemController</p>
  
  <pre><code>def show
      @item = Item.find(params[:id])
      @note = @item.notes.new
      respond_with(@item)
    end
  </code></pre>
  
  <p>NoteController</p>
  
  <pre><code>def create
      @note = @item.notes.build(params[:note])
      flash[:notice] = 'Your note was successfully added!' if @note.save
      respond_with(@item)
    end
  </code></pre>
  
  <p>items/show.html.erb</p>
  
  <pre><code>&lt;%= form_for ([@item, @note]),  :html =&gt; {:id =&gt; 'form-add-item-note'} do |f| %&gt;
  </code></pre>
  
  <p>I have tried </p>
  
  <pre><code>&lt;%=f.error_messages%&gt; 
  &lt;%=error_messages_for :note%&gt;
  &lt;%=error_messages_for :item,:note%&gt; 
  </code></pre>
  
  <p>and even have a template for handling errors</p>
  
  <pre><code>    &lt;%= render "global/error_messages", :target =&gt; @item %&gt;
  </code></pre>
  
  <p>which contains</p>
  
  <pre><code>&lt;% if target.errors.any? %&gt;
  &lt;div id="error_explanation"&gt;
      &lt;h2&gt;&lt;%= pluralize(target.errors.count, "error") %&gt; prohibited this record from being saved:&lt;/h2&gt;
      &lt;ul&gt;
          &lt;% target.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
          &lt;% end %&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I believe I'm losing the errors to the redirect but I can't seem to quite get how to redirect or render the item controller from the failed save in the note create and I would love to be able to pass the error global template the @note and it render the errors</p>