Skip to content
Browse files

Dont use Enumarator on join_association

  • Loading branch information...
1 parent 6e61da2 commit c3872522895dc98be0081c4457f834951dbd11bc @arthurnn arthurnn committed Feb 13, 2014
Showing with 4 additions and 2 deletions.
  1. +4 −2 activerecord/lib/active_record/associations/join_dependency/join_association.rb
View
6 activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -25,7 +25,8 @@ def join_constraints(foreign_table, foreign_klass, node, join_type, tables, scop
joins = []
tables = tables.reverse
- scope_chain_iter = scope_chain.reverse_each
+ scope_chain_index = 0
+ scope_chain = scope_chain.reverse
# The chain starts with the target table, but we want to end with it here (makes
# more sense in this context), so we reverse
@@ -44,13 +45,14 @@ def join_constraints(foreign_table, foreign_klass, node, join_type, tables, scop
constraint = build_constraint(klass, table, key, foreign_table, foreign_key)
- scope_chain_items = scope_chain_iter.next.map do |item|
+ scope_chain_items = scope_chain[scope_chain_index].map do |item|
if item.is_a?(Relation)
item
else
ActiveRecord::Relation.create(klass, table).instance_exec(node, &item)
end
end
+ scope_chain_index += 1
scope_chain_items.concat [klass.send(:build_default_scope)].compact

0 comments on commit c387252

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