diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 13c745f7fdee5..113cb0ab700b0 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -194,7 +194,7 @@ def connection_class # :nodoc: # #connection or #with_connection methods. Connections obtained through # #checkout will not be detected by #active_connection? def active_connection? - @thread_cached_conns[connection_cache_key(current_thread)] + @thread_cached_conns.try(:[], connection_cache_key(current_thread)) end # Signal that the thread is finished with the current connection.