Sha256: edb1dcf237d10a90001927844823f1c8a4891a41a618eadd2be7712ab07b1b0c

Contents?: true

Size: 687 Bytes

Versions: 2

Compression:

Stored size: 687 Bytes

Contents

module EacRailsUtils::Models::TablelessAssociations
  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

2 entries across 2 versions & 1 rubygems

Version Path
eac_rails_utils-0.22.0 lib/eac_rails_utils/models/tableless_associations/association_scope_extension.rb
eac_rails_utils-0.21.0 lib/eac_rails_utils/models/tableless_associations/association_scope_extension.rb