method
delete
v6.1.3.1 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Associations::HasOneAssociation
- 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 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 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?
delete(method = options[:dependent])
public
Hide source
# File activerecord/lib/active_record/associations/has_one_association.rb, line 26 def delete(method = options[:dependent]) if load_target case method when :delete target.delete when :destroy target.destroyed_by_association = reflection target.destroy throw(:abort) unless target.destroyed? when :destroy_async primary_key_column = target.class.primary_key.to_sym id = target.public_send(primary_key_column) 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) ) when :nullify target.update_columns(nullified_owner_attributes) if target.persisted? end end end