method
delete_records
![No documentation Importance_0](https://d2vfyqvduarcvs.cloudfront.net/images/importance_0.png?1349367920)
v3.1.0 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Associations::HasManyThroughAssociation
delete_records(records, method)
private
Hide source
# File activerecord/lib/active_record/associations/has_many_through_association.rb, line 104 def delete_records(records, method) ensure_not_nested through = owner.association(through_reflection.name) scope = through.scoped.where(construct_join_attributes(*records)) case method when :destroy count = scope.destroy_all.length when :nullify count = scope.update_all(source_reflection.foreign_key => nil) else count = scope.delete_all end delete_through_records(through, records) if through_reflection.macro == :has_many && update_through_counter?(method) update_counter(-count, through_reflection) end update_counter(-count) end