When you delete the parent, the
> children's foreign keys are nullified, as expected. But when you do
> parent.child.delete or parent.children.clear, ActiveRecord actually
> deletes the child records, rather than just nullifying them.
>
> In my eyes, if you've set :dependent => :nullify, you're saying
> that the child records should only ever be nullified, not deleted.
> The behaviour I'm seeing seems to be a hang over from when
> setting :dependent always meant 'delete/destroy the children'.
>
> However, I realise that maybe this is just my interpretation of
> what the :dependent => :nullify option is supposed to do. So I'd be
> interested to hear what everyone else thinks.
<...>
Any thoughts/opinions on this yet? Sorry to spam, but it's
potentially destructive behaviour, and I'm keen to see it resolved
one way or the other.
It just do what you ask it to. :dependent specifies what to do with
children when _parent_ is deleted.
With call to parent.child.delete or parent.children.clear you specifically ask
to delete children, and AR just does that.
Regards,
Rimantas
--
http://rimantas.com/
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core