Sha256: e5779196c5d0f02930300c5d967dd1f10693c3689db31b3b642f2be2d73a5c4c

Contents?: true

Size: 487 Bytes

Versions: 39

Compression:

Stored size: 487 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord::Associations
  module ForeignAssociation # :nodoc:
    def foreign_key_present?
      if reflection.klass.primary_key
        owner.attribute_present?(reflection.active_record_primary_key)
      else
        false
      end
    end

    def nullified_owner_attributes
      Hash.new.tap do |attrs|
        attrs[reflection.foreign_key] = nil
        attrs[reflection.type] = nil if reflection.type.present?
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 4 rubygems

Version Path
activerecord-6.0.6.1 lib/active_record/associations/foreign_association.rb
activerecord-6.0.6 lib/active_record/associations/foreign_association.rb
activerecord-6.0.5.1 lib/active_record/associations/foreign_association.rb
activerecord-6.0.5 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.8 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.7 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.6 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.5 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.4 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.3 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.2 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4.1 lib/active_record/associations/foreign_association.rb
activerecord-6.0.4 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.7 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.6 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.5 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.4 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.3 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.2 lib/active_record/associations/foreign_association.rb
activerecord-6.0.3.1 lib/active_record/associations/foreign_association.rb