Flowdock
method

delete_records

Importance_0
Ruby on Rails latest stable (v6.1.7.7) - 0 notes - Class: ActiveRecord::Associations::HasAndBelongsToManyAssociation

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v4.0.2) is shown here.

These similar methods exist in v6.1.7.7:

delete_records(records, method) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb, line 41
        def delete_records(records, method)
          if sql = options[:delete_sql]
            records = load_target if records == :all
            records.each { |record| owner.class.connection.delete(interpolate(sql, record)) }
          else
            relation  = join_table
            condition = relation[reflection.foreign_key].eq(owner.id)

            unless records == :all
              condition = condition.and(
                relation[reflection.association_foreign_key]
                  .in(records.map { |x| x.id }.compact)
              )
            end

            owner.class.connection.delete(relation.where(condition).compile_delete)
          end
        end
Register or log in to add new notes.