diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-10 14:57:45 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-10 14:57:45 -0700 |
commit | c4d0e69ad25e596ae3617e8fe96b91097edbfedb (patch) | |
tree | e2affbb854ecea5c50529fb597f2bb5629560ca7 /activerecord/lib/active_record | |
parent | 0c6c026dec83f7ba1a357abd4427c999523178f6 (diff) | |
download | rails-c4d0e69ad25e596ae3617e8fe96b91097edbfedb.tar.gz rails-c4d0e69ad25e596ae3617e8fe96b91097edbfedb.tar.bz2 rails-c4d0e69ad25e596ae3617e8fe96b91097edbfedb.zip |
pass the parent node to the construct method
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 09039863e5..57a281be05 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -97,16 +97,15 @@ module ActiveRecord parents = {} type_caster = result_set.column_type primary_key - assoc = join_root.children records = result_set.map { |row_hash| primary_id = type_caster.type_cast row_hash[primary_key] parent = parents[primary_id] ||= join_root.instantiate(row_hash) - construct(parent, assoc, row_hash, result_set) + construct(parent, join_root, row_hash, result_set) parent }.uniq - remove_duplicate_results!(base_klass, records, assoc) + remove_duplicate_results!(base_klass, records, join_root.children) records end @@ -185,10 +184,10 @@ module ActiveRecord JoinAssociation.new(reflection, join_root.to_a.length, parent, join_type, alias_tracker) end - def construct(parent, nodes, row, rs) - nodes.each do |node| - association = construct_association(parent, node, row, rs) - construct(association, node.children, row, rs) if association + def construct(ar_parent, parent, row, rs) + parent.children.each do |node| + association = construct_association(ar_parent, node, row, rs) + construct(association, node, row, rs) if association end end |