diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2013-05-09 13:08:44 -0400 |
---|---|---|
committer | Neeraj Singh <neerajdotname@gmail.com> | 2013-10-14 11:59:59 -0400 |
commit | cd9592959f9f16b228ac3f4bc6fc92932253f8dc (patch) | |
tree | faed0751594dc3790c0a575c96c169c7571fe899 /activerecord/lib/active_record/reflection.rb | |
parent | 25649c7fd74219881342b2cb59f97c08f646a4ea (diff) | |
download | rails-cd9592959f9f16b228ac3f4bc6fc92932253f8dc.tar.gz rails-cd9592959f9f16b228ac3f4bc6fc92932253f8dc.tar.bz2 rails-cd9592959f9f16b228ac3f4bc6fc92932253f8dc.zip |
scope_chain should not be mutated for other reflections
Currently `scope_chain` uses same array for building different
`scope_chain` for different associations. During processing
these arrays are sometimes mutated and because of in-place
mutation the changed `scope_chain` impacts other reflections.
Fix is to dup the value before adding to the `scope_chain`.
Fixes #3882.
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r-- | activerecord/lib/active_record/reflection.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index e88c5d17cb..bce7766501 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -574,7 +574,7 @@ module ActiveRecord # Add to it the scope from this reflection (if any) scope_chain.first << scope if scope - through_scope_chain = through_reflection.scope_chain + through_scope_chain = through_reflection.scope_chain.map(&:dup) if options[:source_type] through_scope_chain.first << |