Sha256: 68ee3088801ac8059123b4176f5e8d12cfd0fccf5b8905454b0d0aeb562f4984

Contents?: true

Size: 658 Bytes

Versions: 15

Compression:

Stored size: 658 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

15 entries across 15 versions & 1 rubygems

Version Path
composite_primary_keys-14.0.6 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.7 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.6 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-14.0.5 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.5 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.4 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-14.0.4 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-14.0.3 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.3 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-14.0.2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-13.0.2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-14.0.1 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-11.0.0.rc2 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-8.1.0 lib/composite_primary_keys/associations/association.rb
composite_primary_keys-8.0.0 lib/composite_primary_keys/associations/association.rb