Module: EacRailsUtils::Patches::Rails4::ActiveRecordAssociationsAssociationScope

Defined in:
lib/eac_rails_utils/patches/rails_4/active_record_associations_association_scope.rb

Instance Method Summary collapse

Instance Method Details

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



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

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