Flowdock
method

handle_dependency

Importance_0
v6.1.3.1 - Show latest stable - 0 notes - Class: ActiveRecord::Associations::BelongsToAssociation
handle_dependency() public

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/belongs_to_association.rb, line 7
      def handle_dependency
        return unless load_target

        case options[:dependent]
        when :destroy
          target.destroy
          raise ActiveRecord::Rollback unless target.destroyed?
        when :destroy_async
          id = owner.public_send(reflection.foreign_key.to_sym)
          primary_key_column = reflection.active_record_primary_key.to_sym

          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
Register or log in to add new notes.