method
handle_dependency
v7.1.3.2 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Associations::BelongsToAssociation
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
handle_dependency()
public
Hide source
# File activerecord/lib/active_record/associations/belongs_to_association.rb, line 7 def handle_dependency return unless load_target case options[:dependent] when :destroy raise ActiveRecord::Rollback unless target.destroy when :destroy_async if reflection.foreign_key.is_a?(Array) primary_key_column = reflection.active_record_primary_key.map(&:to_sym) id = reflection.foreign_key.map { |col| owner.public_send(col.to_sym) } else primary_key_column = reflection.active_record_primary_key.to_sym id = owner.public_send(reflection.foreign_key.to_sym) end enqueue_destroy_association( owner_model_name: owner.class.to_s, owner_id: owner.id, association_class: reflection.klass.to_s, association_ids: [id], association_primary_key_column: primary_key_column, ensuring_owner_was_method: options.fetch(:ensuring_owner_was, nil) ) else target.public_send(options[:dependent]) end end