Deletes the records according to the :dependent option.
# File activerecord/lib/active_record/associations/has_many_association.rb, line 110
def delete_records(records, method)
if method == :destroy
records.each(&:destroy!)
update_counter(-records.length) unless inverse_updates_counter_cache?
else
if records == :all || !reflection.klass.primary_key
scope = self.scope
else
scope = self.scope.where(reflection.klass.primary_key => records)
end
if method == :delete_all
update_counter(-scope.delete_all)
else
update_counter(-scope.update_all(reflection.foreign_key => nil))
end
end
end