Sha256: 3e9d4bf5a926e21572936afc2ac5d3bad94ee08e3dc812fe57055e84230da999

Contents?: true

Size: 555 Bytes

Versions: 20

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

require 'activemodel/associations'

module EacRailsUtils
  module Patches
    module Rails4
      module ActiveRecordAssociationsAssociationScope
        def add_constraints(scope, owner, association_klass, *extra_args)
          if extra_args.any?
            refl = extra_args.first
            if refl.options[:active_model]
              target_ids = refl.options[:target_ids]
              return scope.where(id: owner[target_ids])
            end
          end

          super
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
eac_rails_utils-0.23.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.22.3 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.22.2 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.22.1 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.22.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.21.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.20.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.19.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.18.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.17.2 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.17.1 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.17.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.16.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.15.2 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.15.1 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.15.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.14.1 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.14.0 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.13.5 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb
eac_rails_utils-0.13.4 lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb