From c2fc9848b1495768a4c550e4cc532882146902c9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 7 Nov 2014 16:23:15 -0800 Subject: default scopes should break the cache on has_many. if you specify a default scope on a model, it will break caching. We cannot predict what will happen inside the scope, so play it safe for now. fixes #17495 --- activerecord/lib/active_record/associations/collection_association.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index bdfd569be2..4411e5ae62 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -409,7 +409,8 @@ module ActiveRecord def get_records if reflection.scope_chain.any?(&:any?) || scope.eager_loading? || - klass.current_scope + klass.current_scope || + klass.default_scopes.any? return scope.to_a end -- cgit v1.2.3