Sha256: 5f0eff1f6b1a4270accf57560c4ec0406a9505addbf07893f814dd376c075cf3

Contents?: true

Size: 668 Bytes

Versions: 4

Compression:

Stored size: 668 Bytes

Contents

module ActiveModel::Associations
  module AssociationScopeExtension
    if ActiveRecord.version >= Gem::Version.new("5.0.0.beta")
      def add_constraints(scope, owner, association_klass, refl, chain_head, chain_tail)
        if refl.options[:active_model]
          target_ids = refl.options[:target_ids]
          return scope.where(id: owner[target_ids])
        end

        super
      end
    else
      def add_constraints(scope, owner, assoc_klass, refl, tracker)
        if refl.options[:active_model]
          target_ids = refl.options[:target_ids]
          return scope.where(id: owner[target_ids])
        end

        super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
eac_rails_utils-0.20.0 lib/active_model/associations/association_scope_extension.rb
activemodel-associations-0.2.0 lib/active_model/associations/association_scope_extension.rb
activemodel-associations-0.2.0.beta2 lib/active_model/associations/association_scope_extension.rb
activemodel-associations-0.2.0.beta1 lib/active_model/associations/association_scope_extension.rb