Sha256: e0e93fafea0a80cd0156d345b1a3a5f33c11f57b66f459d2e7e1176c70f55815

Contents?: true

Size: 681 Bytes

Versions: 37

Compression:

Stored size: 681 Bytes

Contents

module ActiveRecord
  module Associations
    class Association
      def creation_attributes
        attributes = {}

        if (reflection.has_one? || reflection.collection?) && !options[:through]
          # CPK
          # attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key]
          Array(reflection.foreign_key).zip(Array(reflection.active_record_primary_key)).each do |key1, key2|
            attributes[key1] = owner[key2]
          end

          if reflection.options[:as]
            attributes[reflection.type] = owner.class.base_class.name
          end
        end

        attributes
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
composite_primary_keys-13.0.1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.0 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.10 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.9 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.8 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.6 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.5 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.4 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.3 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-11.3.1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-8.1.8 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.0 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.0.rc5 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.0.rc4 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.0.rc3 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.0.rc2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-12.0.0.rc1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-8.1.7 lib/composite_primary_keys/associations/association.rb