I've just submitted my first patch, and I'd love to get some feedback
on it. This patching Rails thing is a bit daunting if you haven't done
it before! Not sure if I'm on the right track.
From the description:
A has_one or has_many relationship with :dependent set either :nullify
will incorrectly destroy the associated objects when the association
is reassigned or set to nil. Instead, the associated objects' foreign
keys should be nullified, as they are when the parent object is
For example, given this association:
has_one :george, :dependent => :nullify
The following will cause george to be destroyed.
fred = Fred.create
george = George.create(:fred_id => fred)
fred.george = nil
The issue also extends to :dependent => :delete and :dependent
=> :delete_all. Associated objects are destroyed rather than deleted
when the association is reassigned.
The attached patch fixes this issue and makes :dependent behaviour
consistent in all circumstances the I can think of.