This project is archived and is in readonly mode.
rails 2.3.8 : accepts_nested_attributes_for and attributes= broken
Reported by ajoulie | March 24th, 2011 @ 08:21 AM
It seems that combinaison of accepts_nested_attributes_for and
attributes= is broken into rails 2.3.8.
The problem occurs whith following models :
class Book < ActiveRecord::Base
has_many :authors
accepts_nested_attributes_for authors
end
class Author < ActiveRecord::Base
belongs_to :book
end
and a params hash like this :
params = {:name=>"a great book", "authors_attributes"=>{"1"=>{:id"=>"2", "_destroy"=>"", :name => "Boney M"}}}
Calling
book.attributes=params
do not set @loaded to true into authors AssociationProxy of
object book. So the next call to
book.authors
will reload author objects from database.
This was not the case in rails 2.3.5, What is the normal behaviour ?
ps : I saw ticket 2646 and it seems to me to be a different problem.
No comments found
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>