If :dependent is not set on a has_many association there is currently a confusing inconsistency between doing a destroy on the main object and doing a delete on the association.
Example:
class Directory < ActiveRecord::Base
has_many :files
end
directory.destroy will not do anything to the files, while directory.files.delete(file) will set the directory_id of the file object to NULL. This inconsistency is confusing.
The attached patch adds a further :dependent option :none to maintain backward compatibility for everyone who doesn't have :dependent set at all. So,
class Directory < ActiveRecord::Base
has_many :files, :dependent => :none
end
Now the :dependent => :none set directory.destroy will not do anything to the files and in a consistent way directory.files.delete(file) will remove the file from the collection but not do anything to the file.
The patch also makes directories.files.delete(file) and directories.files.clear also behave consistently when :dependent => :nullify, :destroy and :delete_all.
This patch covers the same ground as #5209 and #6904 but hopefully in a more consistent way.