title: Rails bug: accepts_nested_attributes_for is not updating my has_many association
body: <p>I have 2 models:</p>
  
  <pre><code>class Book &lt; ActiveRecord::Base
    has_many :book_versions
    accepts_nested_attributes_for :book_versions, allow_destroy: true
    validates_associated :book_versions
  
  class BookVersion &lt; ActiveRecord::Base
    has_many :collection_items
    has_many :collections, through: :collection_items
    belongs_to :book
    validates_presence_of :price, :isbn #&lt;-- validates presence
  </code></pre>
  
  <p>Here are my params. Notice how I leave the <code>price</code> of book_version with name <code>bb</code> blank. This should be firing off the <code>validates_presence_of :price</code> validation in the <code>BookVersion</code> model (but it doesn't):</p>
  
  <p>"book"=>{"title"=>"zzzzzz", "subtitle"=>"", "author_ids"=>[""], "illustrator_ids"=>[""], "award_ids"=>[""], "theme_ids"=>[""], "publication_date"=>"", "imprint_id"=>"1", "language_ids"=>[""], "eng_vers_id"=>"", "book_versions_attributes"=>{"0"=>{"book_id"=>"2848", "name"=>"alt", "isbn"=>"", "price"=>"", "famis_number"=>"", "famis_price"=>"", "weight_in_pounds"=>""}, "1"=>{"book_id"=>"2848", "name"=>"bb", "isbn"=>"123123123123", "price"=>"", "famis_number"=>"", "famis_price"=>"", "weight_in_pounds"=>"1.0", "inventory"=>"08", "id"=>"1030"},</p>
  
  <p>When I do <code>@book.update_attributes(params[:book])</code> in my controller, none of the <code>book_versions</code> update even though everything seems valid:</p>
  
  <pre><code>    &gt;&gt; @book.update_attributes(params[:book])
      =&gt; true
      &gt;&gt; @book.book_versions
      =&gt; [#&lt;BookVersion id: 1030, book_id: 2848, name: "bb", isbn: "123123123123", inventory: "08", price: #&lt;BigDecimal:7fc484885b80,'0.1122E2',18(18)&gt;, famis_price: nil, famis_number: "", weight_in_pounds: #&lt;BigDecimal:7fc4848861c0,'0.1E1',9(18)&gt;, width: nil, height: nil, thickness: nil&gt;, #&lt;BookVersion id: 1031, book_id: 2848, name: "lb", isbn: "12312333333", inventory: "02", price: #&lt;BigDecimal:7fc484886670,'0.2244E2',18(18)&gt;, famis_price: nil, famis_number: "", weight_in_pounds: #&lt;BigDecimal:7fc484886760,'0.1E1',9(18)&gt;, width: nil, height: nil, thickness: nil&gt;, #&lt;BookVersion id: 1032, book_id: 2848, name: "hc", isbn: "111213213131", inventory: nil, price: #&lt;BigDecimal:7fc4848869e0,'0.1212E4',9(18)&gt;, famis_price: nil, famis_number: "", weight_in_pounds: #&lt;BigDecimal:7fc484886d28,'0.1E1',9(18)&gt;, width: nil, height: nil, thickness: nil&gt;]
      &gt;&gt; @book.book_versions.map(&amp;:price)
      =&gt; [#&lt;BigDecimal:7fc484885b80,'0.1122E2',18(18)&gt;, #&lt;BigDecimal:7fc484886670,'0.2244E2',18(18)&gt;, #&lt;BigDecimal:7fc4848869e0,'0.1212E4',9(18)&gt;]
      &gt;&gt; @book.book_versions.map(&amp;:price).map(&amp;:to_f)
      =&gt; [11.22, 22.44, 1212.0]
      &gt;&gt; @book.save
      =&gt; true
      &gt;&gt; @book.book_versions.map(&amp;:price).map(&amp;:to_f)
      =&gt; [11.22, 22.44, 1212.0] #&lt;-- one of these should be `nil`.
  </code></pre>
  
  <p>What's going on? The form works perfectly fine when I am creating a <code>Book</code> with many <code>BookVersion</code>s. However, it does not update or validate anything when I'm updating an existing book with existing book versions.</p>
  
  <p>This is a continuation of my question here: <a href="https://stackoverflow.com/questions/21632576/activerecord-validates-associated-does-not-work-when-updating-model">ActiveRecord: validates_associated does not work when updating model?</a></p>
  
  <p>UPDATE ====</p>
  
  <p>Uh... I think it's a bug in rails? Look at what happens:</p>
  
  <pre><code>    &gt;&gt; @book.update_attributes(params[:book])
      =&gt; true
      &gt;&gt; @book.book_versions
      =&gt; [#&lt;BookVersion id: 1030, book_id: 2848, name: "bb", isbn: "123123123123", inventory: "08", price: #&lt;BigDecimal:7fc487ee9488,'0.1122E2',18(18)&gt;, famis_price: nil, famis_number: "", weight_in_pounds: #&lt;BigDecimal:7fc487ee9118,'0.1E1',9(18)&gt;, width: nil, height: nil, thickness: nil&gt;, #&lt;BookVersion id: 1031, book_id: 2848, name: "lb", isbn: "12312333333", inventory: "02", price: #&lt;BigDecimal:7fc487ee8f88,'0.2244E2',18(18)&gt;, famis_price: nil, famis_number: "", weight_in_pounds: #&lt;BigDecimal:7fc487ee8e98,'0.1E1',9(18)&gt;, width: nil, height: nil, thickness: nil&gt;, #&lt;BookVersion id: 1032, book_id: 2848, name: "hc", isbn: "111213213131", inventory: nil, price: #&lt;BigDecimal:7fc487ee8b50,'0.1212E4',9(18)&gt;, famis_price: nil, famis_number: "", weight_in_pounds: #&lt;BigDecimal:7fc487ee89c0,'0.1E1',9(18)&gt;, width: nil, height: nil, thickness: nil&gt;]
      &gt;&gt; @book.update_attributes(params[:book])
      =&gt; false
  </code></pre>
  
  <p>But that is only when I use better errors and freeze the controller before <code>update_attributes</code>. When I actually put <code>@book.book_versions</code> in the controller right before I update the attributes and try running it, it still doesn't work.</p>