Sha256: e2298c54c28a6c9324704c710d3edab99290c7df70bc81eb3a53714f17ead5d3

Contents?: true

Size: 706 Bytes

Versions: 10

Compression:

Stored size: 706 Bytes

Contents

module ActiveRecord
  module Associations
    module ThroughAssociation
      alias :original_construct_join_attributes :construct_join_attributes

      def construct_join_attributes(*records)
        # CPK
        if source_reflection.klass.composite?
          ensure_mutable

          ids = records.map do |record|
            source_reflection.association_primary_key(reflection.klass).map do |key|
              record.send(key)
            end
          end

          cpk_in_predicate(through_association.scope.klass.arel_table, source_reflection.foreign_key, ids)
        else
          original_construct_join_attributes(*records)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
composite_primary_keys-12.0.2 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-11.3.1 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.1 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.0 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.0.rc5 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.0.rc4 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.0.rc3 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.0.rc2 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-12.0.0.rc1 lib/composite_primary_keys/associations/through_association.rb
composite_primary_keys-11.2.0 lib/composite_primary_keys/associations/through_association.rb