Module: EacRailsUtils::Patches::ActiveModelAssociations::ScopeExtensionPatch

Defined in:
lib/eac_rails_utils/patches/active_model_associations.rb

Instance Method Summary collapse

Instance Method Details

#add_constraints(scope, owner, association_klass, *extra_args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/eac_rails_utils/patches/active_model_associations.rb', line 10

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