Sha256: 9c67601571a371d7ba8452a1ce17aa4fd61c5ceeaf16b52faff5f01ac6c0907d

Contents?: true

Size: 654 Bytes

Versions: 27

Compression:

Stored size: 654 Bytes

Contents

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

        if reflection.macro.in?([:has_one, :has_many]) && !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

27 entries across 27 versions & 1 rubygems

Version Path
composite_primary_keys-5.0.14 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.13 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.12 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.11 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.10 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.9 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.8 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.6 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.5 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.4 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.0 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-5.0.0.rc1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-4.1.2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-4.1.1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-4.0.0 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-4.0.0.beta9 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-4.0.0.beta8 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-4.0.0.beta7 lib/composite_primary_keys/associations/association.rb