diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-14 09:28:55 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-02-14 15:33:30 -0200 |
commit | c5451777b038c5e48567f69256986ae42a2cde48 (patch) | |
tree | dbbc7e1735ba0250ded7403d4ac0baf9d8e731d7 /activerecord/lib | |
parent | ee3e3a90f31af5845849dc631ff301e79c95b28a (diff) | |
download | rails-c5451777b038c5e48567f69256986ae42a2cde48.tar.gz rails-c5451777b038c5e48567f69256986ae42a2cde48.tar.bz2 rails-c5451777b038c5e48567f69256986ae42a2cde48.zip |
Merge pull request #9252 from senny/8423_hmt_preloading_bug
don't cache invalid subsets when preloading hmt associations
Conflicts:
activerecord/CHANGELOG.md
activerecord/test/cases/associations/eager_test.rb
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/through_association.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb index ad6374d09a..0f1336bd00 100644 --- a/activerecord/lib/active_record/associations/preloader/through_association.rb +++ b/activerecord/lib/active_record/associations/preloader/through_association.rb @@ -37,7 +37,8 @@ module ActiveRecord through_records = Array.wrap(owner.send(through_reflection.name)) # Dont cache the association - we would only be caching a subset - if reflection.options[:source_type] && through_reflection.collection? + if (through_scope != through_reflection.klass.unscoped) || + (reflection.options[:source_type] && through_reflection.collection?) owner.association(through_reflection.name).reset end |