Skip to content
This repository
Browse code

Make use of helpers in AssociationReflection

  • Loading branch information...
commit 9db4c07e0bdf60982d08cb26035573995404eb98 1 parent 3fa61cc
Jon Leighton authored January 26, 2011
8  activerecord/lib/active_record/associations/through_association.rb
@@ -47,9 +47,9 @@ def construct_joins
47 47
           conditions = []
48 48
 
49 49
           if @reflection.source_reflection.macro == :belongs_to
50  
-            reflection_primary_key = @reflection.source_reflection.options[:primary_key] ||
51  
-                                     @reflection.klass.primary_key
  50
+            reflection_primary_key = @reflection.source_reflection.association_primary_key
52 51
             source_primary_key     = @reflection.source_reflection.foreign_key
  52
+
53 53
             if @reflection.options[:source_type]
54 54
               column = @reflection.source_reflection.foreign_type
55 55
               conditions <<
@@ -57,8 +57,8 @@ def construct_joins
57 57
             end
58 58
           else
59 59
             reflection_primary_key = @reflection.source_reflection.foreign_key
60  
-            source_primary_key     = @reflection.source_reflection.options[:primary_key] ||
61  
-                                     @reflection.through_reflection.klass.primary_key
  60
+            source_primary_key     = @reflection.source_reflection.active_record_primary_key
  61
+
62 62
             if @reflection.source_reflection.options[:as]
63 63
               column = "#{@reflection.source_reflection.options[:as]}_type"
64 64
               conditions <<

0 notes on commit 9db4c07

Please sign in to comment.
Something went wrong with that request. Please try again.