Class: ActiveRecord::Associations::Preloader::BelongsTo

Inherits:
Object
  • Object
show all
Defined in:
lib/composite_primary_keys/associations/preloader/belongs_to.rb

Instance Method Summary collapse

Instance Method Details

#query_scope(ids) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/composite_primary_keys/associations/preloader/belongs_to.rb', line 5

def query_scope(ids)
  # CPK
  # scope.where(association_key.in(ids))

  if association_key_name.is_a?(Array)
    predicate = cpk_in_predicate(table, association_key_name, ids)
    scope.where(predicate)
  else
    scope.where(association_key.in(ids))
  end
end