aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/through_association.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/through_association.rb b/activerecord/lib/active_record/associations/through_association.rb
index be1fc79846..c840a16160 100644
--- a/activerecord/lib/active_record/associations/through_association.rb
+++ b/activerecord/lib/active_record/associations/through_association.rb
@@ -47,9 +47,9 @@ module ActiveRecord
conditions = []
if @reflection.source_reflection.macro == :belongs_to
- reflection_primary_key = @reflection.source_reflection.options[:primary_key] ||
- @reflection.klass.primary_key
+ reflection_primary_key = @reflection.source_reflection.association_primary_key
source_primary_key = @reflection.source_reflection.foreign_key
+
if @reflection.options[:source_type]
column = @reflection.source_reflection.foreign_type
conditions <<
@@ -57,8 +57,8 @@ module ActiveRecord
end
else
reflection_primary_key = @reflection.source_reflection.foreign_key
- source_primary_key = @reflection.source_reflection.options[:primary_key] ||
- @reflection.through_reflection.klass.primary_key
+ source_primary_key = @reflection.source_reflection.active_record_primary_key
+
if @reflection.source_reflection.options[:as]
column = "#{@reflection.source_reflection.options[:as]}_type"
conditions <<