Skip to content

Commit

Permalink
Make use of helpers in AssociationReflection
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Jan 30, 2011
1 parent 3fa61cc commit 9db4c07
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -47,18 +47,18 @@ def construct_joins
conditions = [] conditions = []


if @reflection.source_reflection.macro == :belongs_to if @reflection.source_reflection.macro == :belongs_to
reflection_primary_key = @reflection.source_reflection.options[:primary_key] || reflection_primary_key = @reflection.source_reflection.association_primary_key
@reflection.klass.primary_key
source_primary_key = @reflection.source_reflection.foreign_key source_primary_key = @reflection.source_reflection.foreign_key

if @reflection.options[:source_type] if @reflection.options[:source_type]
column = @reflection.source_reflection.foreign_type column = @reflection.source_reflection.foreign_type
conditions << conditions <<
right[column].eq(@reflection.options[:source_type]) right[column].eq(@reflection.options[:source_type])
end end
else else
reflection_primary_key = @reflection.source_reflection.foreign_key reflection_primary_key = @reflection.source_reflection.foreign_key
source_primary_key = @reflection.source_reflection.options[:primary_key] || source_primary_key = @reflection.source_reflection.active_record_primary_key
@reflection.through_reflection.klass.primary_key
if @reflection.source_reflection.options[:as] if @reflection.source_reflection.options[:as]
column = "#{@reflection.source_reflection.options[:as]}_type" column = "#{@reflection.source_reflection.options[:as]}_type"
conditions << conditions <<
Expand Down

0 comments on commit 9db4c07

Please sign in to comment.