From 6d961242848ffe0eac69f190fd02f44aaeef3e0a Mon Sep 17 00:00:00 2001 From: Tom Ward Date: Sat, 14 May 2011 10:31:00 +0100 Subject: Reset ActiveRecord::LogSubscriber runtime at the start of each request Previously the runtime was reset implicitly when #cleanup_view_runtime was called at the end of most requests. However, this doesn't happen when the request redirects, or send_file is called. Consequently, the ActiveRecord runtime recorded in the logs included the time taken for both the current request and the previous redirect. Explicitly resetting at the start of each request ensures that this can't happen, no matter what occurs previously. --- activerecord/lib/active_record/railties/controller_runtime.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/lib/active_record/railties') diff --git a/activerecord/lib/active_record/railties/controller_runtime.rb b/activerecord/lib/active_record/railties/controller_runtime.rb index bc6ca936c0..a0eecf4f46 100644 --- a/activerecord/lib/active_record/railties/controller_runtime.rb +++ b/activerecord/lib/active_record/railties/controller_runtime.rb @@ -9,6 +9,11 @@ module ActiveRecord attr_internal :db_runtime + def process_action(action, *args) + ActiveRecord::LogSubscriber.reset_runtime + super + end + def cleanup_view_runtime if ActiveRecord::Base.connected? db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime -- cgit v1.2.3