delete_records(records, method)
private
Deletes the records according to the :dependent option.
Show source
def delete_records(records, method)
if method == :destroy
records.each { |r| r.destroy }
update_counter(-records.length) unless inverse_updates_counter_cache?
else
keys = records.map { |r| r[reflection.association_primary_key] }
scope = scoped.where(reflection.association_primary_key => keys)
if method == :delete_all
update_counter(-scope.delete_all)
else
update_counter(-scope.update_all(reflection.foreign_key => nil))
end
end
end