Hi,
I have a parent model like this:
class Parent < ActiveRecord::Base
belongs_to :grand_parent
has_many :blond_children, :dependent => :destroy
has_many :brunette_children, :dependent => :destroy
has_many :dogs, :dependent => :destroy
accepts_nested_attributes_for :blond_children, :brunette_children, :dogs,
:allow_destroy => true
...
end
I can't seem to get the attributes of the children to change with
attempts like the following
parent_instance.blond_children_attributes = {"1"=>{:_destroy=>true},
"2"=>{:_destroy=>true}}
parent_instance.save
parent_instance.reload.blond_children.should == <some new number
reflecting deletion>
I've also tried this with hashes and using #update_attributes on the
parent_instance.
I keep experimenting, but I can't get expected results. I'm wondering
if maybe the problems are:
1) on an update, all children and their attributes need to be
explicitly mentioned, even if the value is ""
2) where should the parent and child ids appear in any attempts to
update child attributes?
I might guess some readers have banged their head on something like
this in the past, any pointers?
Thanks,
Lille
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.