From 68c08111fbb78befd1811136a6cbcb157bd3e914 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 11 Oct 2013 16:46:28 -0700 Subject: [PATCH] we always have a reflection and it is on the node --- .../lib/active_record/associations/join_dependency.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 54dcd6759075b..650f3a986a7b5 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -149,7 +149,7 @@ def deep_copy(parent, node) def remove_duplicate_results!(base, records, associations) associations.each do |node| - reflection = base.reflect_on_association(node.name) + reflection = node.reflection remove_uniq_by_reflection(reflection, records) parent_records = [] @@ -189,7 +189,7 @@ def build_scalar(reflection, parent, join_type) end def remove_uniq_by_reflection(reflection, records) - if reflection && reflection.collection? + if reflection.collection? records.each { |record| record.send(reflection.name).target.uniq! } end end