Class: ActiveRecord::Reflection::AbstractReflection

Inherits:
Object
  • Object
show all
Defined in:
lib/composite_primary_keys/reflection.rb

Instance Method Summary collapse

Instance Method Details

#build_join_constraint(table, foreign_table) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/composite_primary_keys/reflection.rb', line 4

def build_join_constraint(table, foreign_table)
  key         = join_keys.key
  foreign_key = join_keys.foreign_key

  # CPK
  #constraint = table[key].eq(foreign_table[foreign_key])
  constraint = cpk_join_predicate(table, key, foreign_table, foreign_key)

  if klass.finder_needs_type_condition?
    table.create_and([constraint, klass.send(:type_condition, table)])
  else
    constraint
  end
end