Nested Model Destruction

Hey all,

I'm using nested model creation in my forms, but I've noticed that
when I go to try and destroy a nested model, the backing DB row gets
destroyed but the child object is never set back to nil as I expected
it to be. This leaves me with an object that doesn't have a backing
DB row. The object is, however, frozen and I can call "destroyed?" on
the object which returns true. Is this expected and defined
behavior? I couldn't find this referenced anywhere as it seems that
the docs indicate the object would be set back to nil.

I'm simply resetting the object to nil if it has been destroyed after
I save the record, so this isn't a problem, just not something I
expected. Maybe the docs should be updated?

Some background info: I'm using rails 2.3.5 running on jruby-1.3.1.
This is a has_one relationship and :allow_destroy is set to true in
the parent model.

Documentation I was looking at:




Maybe this can help (taken from Rails Guides - :dependent

If you set the :dependent option to :destroy, then deleting this
object will call the destroy method on the associated object to delete
that object. If you set the :dependent option to :delete, then
deleting this object will delete the associated object without calling
its destroy method.


Thanks for the response.

I'm not actually deleting the parent object, just deleting a nested
object (the child) from a has_one relationship. Everything is
working, just simply behaving differently from the documentation. I
just wanted to confirm that I am seeing the appropriate behavior. It
seems the documentation may be out of date.