title: Using accepts_nested_attributes_for on a join table with its own attributes - Duplicate rows
body: <p>I have the following three models <strong>(Rails 2.3.8)</strong></p>
  
  <pre><code>    class Outbreak &lt; ActiveRecord::Base
          has_many :incidents, :dependent =&gt; :destroy
          has_many :locations, :through =&gt; :incidents
  
          accepts_nested_attributes_for :incidents, :allow_destroy =&gt; true
          accepts_nested_attributes_for :locations, :allow_destroy =&gt; true, :reject_if =&gt; proc { |attrs| attrs.all? { |k, v| v.blank? } }
  
      end
  
     class Incident &lt; ActiveRecord::Base
          belongs_to :outbreak
          belongs_to :location
     end
  
  
     class Location &lt; ActiveRecord::Base
   has_many :incidents
   has_many :outbreaks, :through =&gt; :incidents
  
       accepts_nested_attributes_for :incidents, :allow_destroy =&gt; true
  
     end
  </code></pre>
  
  <p>The parameters from the form seem to be ok</p>
  
  <p>"outbreak"=>{
  "locations_attributes"=>{"0"=>{"lon"=>"-1.39", "placename"=>"wetwe", "hpu_id"=>"15", "postcode"=>"so1 1aa", "region_id"=>"10", "address_1"=>"", "town"=>"Bargate", "address_2"=>"", "address_3"=>"", "lat"=>"50.89"}},"incidents_attributes"=>{"0"=>{"subtype_id"=>"7", "category_id"=>"1", "detail"=>"", "subcategory_id"=>"2"}}
  }</p>
  
  <p>But when the Outbreak is saved 3 rows are created in the Incidents table (the join table) and a single row in the Outbreak and Location tables.</p>
  
  <p>The rows in the Incidents table are not fully populated from the params as follows:</p>
  
  <pre><code>id outbreak_id location_id category_id subcategory_id subtype_id detail  created_at    updated_at 
  
   57 23   NULL     1       2           7                          2010-11-25 14:45:18.385905  2010-11-25 14:45:18.385905 
   58 23   27         NULL       NULL        NULL    NULL           2010-11-25 14:45:18.39828  2010-11-25 14:45:18.39828 
   59 23   27         NULL         NULL     NULL      NULL           2010-11-25 14:45:18.403051  2010-11-25 14:45:18.403051 
  </code></pre>
  
  <p>This must be due to the either the format of the parameters or the multiple accepts_nested_attributes_for methods - how do I have just a single row being entered in the Incidents table with all of the parameters information?</p>