From 009b2a54344eb2463fa4018d9b20cdfc4c0495ac Mon Sep 17 00:00:00 2001 From: Arthur Neves Date: Tue, 14 Jun 2016 12:31:08 -0400 Subject: Respect the current `connected?` method when calling `cache` Before we enable query caching we check if the connection is connected. Before this fix we were always checking against the main connection, and not the model connection. --- activerecord/lib/active_record/query_cache.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/query_cache.rb b/activerecord/lib/active_record/query_cache.rb index ca12a603da..07d863d15e 100644 --- a/activerecord/lib/active_record/query_cache.rb +++ b/activerecord/lib/active_record/query_cache.rb @@ -5,7 +5,7 @@ module ActiveRecord # Enable the query cache within the block if Active Record is configured. # If it's not, it will execute the given block. def cache(&block) - if ActiveRecord::Base.connected? + if connected? connection.cache(&block) else yield @@ -15,7 +15,7 @@ module ActiveRecord # Disable the query cache within the block if Active Record is configured. # If it's not, it will execute the given block. def uncached(&block) - if ActiveRecord::Base.connected? + if connected? connection.uncached(&block) else yield -- cgit v1.2.3