Sha256: a09853709c738233f17830bce08becadb5e6b9d29601149c6829fe31ed862837
Contents?: true
Size: 965 Bytes
Versions: 11
Compression:
Stored size: 965 Bytes
Contents
# frozen_string_literal: true require 'active_model/associations/hooks' require 'activemodel/associations' module EacRailsUtils module Patches module ActiveModelAssociations module ScopeExtensionPatch 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 module ActiveModel module Associations module Hooks def self.init return unless ::Rails.version < '5' ActiveSupport.on_load(:active_record) do ActiveRecord::Associations::AssociationScope.prepend( ::EacRailsUtils::Patches::ActiveModelAssociations::ScopeExtensionPatch ) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems