The :dependent => :nullify option currently gives inconsistent behaviour. It will nullify the child records when the parent is deleted, as expected. But in other situations it will delete the child records rather than nullifying them. For example:
For a has_many :children, :dependent => :nullify, the following statements result in deleted children:
- parent.children.delete(a_child)
- parent.children.clear
And for a has_one :child, :dependent => :nullify, the following statement results in a deleted child:
If I understand the idea of :nullify correctly, you would expect these statements to nullify the child[ren], not delete them.
This patch (with tests) attempts to fix the problem by doing some explicit checking for the :nullify option, and reverting back to the normal non-dependent behaviour (i.e. just nullifying the foreign keys) where appropriate.