method
delete_records

v3.2.13 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Associations::HasAndBelongsToManyAssociation
delete_records(records, method)
private
Hide source
# File activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb, line 45 def delete_records(records, method) if sql = options[:delete_sql] records = load_target if records == :all records.each { |record| owner.connection.delete(interpolate(sql, record)) } else relation = join_table stmt = relation.where(relation[reflection.foreign_key].eq(owner.id). and(relation[reflection.association_foreign_key].in(records.map { |x| x.id }.compact)) ).compile_delete owner.connection.delete stmt end end