method
delete_or_destroy
v4.2.1 -
Show latest stable
- Class:
ActiveRecord::Associations::CollectionAssociation
delete_or_destroy(records, method)private
No documentation available.
# File activerecord/lib/active_record/associations/collection_association.rb, line 516
def delete_or_destroy(records, method)
records = records.flatten
records.each { |record| raise_on_type_mismatch!(record) }
existing_records = records.reject { |r| r.new_record? }
if existing_records.empty?
remove_records(existing_records, records, method)
else
transaction { remove_records(existing_records, records, method) }
end
end