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(&:destroy!)
update_counter(-records.length) unless reflection.inverse_updates_counter_cache?
else
query_constraints = reflection.klass.composite_query_constraints_list
values = records.map { |r| query_constraints.map { |col| r._read_attribute(col) } }
scope = self.scope.where(query_constraints => values)
update_counter(-delete_count(method, scope))
end
end