diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 15:39:39 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-17 15:39:39 -0700 |
commit | 18fe96cc168927a6508478f9ad127d57c1ad56dd (patch) | |
tree | 5030c2e3b586c4b5c74b63992c3deeafe5876899 | |
parent | 2eecc0d8dccf7f12518e05a72192eb853e5ee474 (diff) | |
download | rails-18fe96cc168927a6508478f9ad127d57c1ad56dd.tar.gz rails-18fe96cc168927a6508478f9ad127d57c1ad56dd.tar.bz2 rails-18fe96cc168927a6508478f9ad127d57c1ad56dd.zip |
stop doing assingments in an iterator
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index e4d17451dc..b81aecb4e5 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -106,12 +106,16 @@ module ActiveRecord ] end - scope_chain_items.each do |item| + constraint = scope_chain_items.inject(constraint) do |chain, item| unless item.is_a?(Relation) item = ActiveRecord::Relation.new(reflection.klass, table).instance_exec(self, &item) end - constraint = constraint.and(item.arel.constraints) unless item.arel.constraints.empty? + if item.arel.constraints.empty? + chain + else + chain.and(item.arel.constraints) + end end manager.from(join(table, constraint)) |