diff options
author | José Valim <jose.valim@gmail.com> | 2010-07-25 21:01:49 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-25 21:01:49 +0200 |
commit | 331df84cc943e08459463d322ca2510490c73b7e (patch) | |
tree | 646bad209dfe213356d68fb9e16830bcb187aa02 /activerecord | |
parent | 304c49b1468ce71beb7e3ea0ca4c5add73a1534e (diff) | |
download | rails-331df84cc943e08459463d322ca2510490c73b7e.tar.gz rails-331df84cc943e08459463d322ca2510490c73b7e.tar.bz2 rails-331df84cc943e08459463d322ca2510490c73b7e.zip |
Cache connection access.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/log_subscriber.rb | 5 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/controller_runtime.rb | 5 |
2 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb index d7b99d796d..f7ae5587ed 100644 --- a/activerecord/lib/active_record/log_subscriber.rb +++ b/activerecord/lib/active_record/log_subscriber.rb @@ -6,6 +6,7 @@ module ActiveRecord end def sql(event) + connection = ActiveRecord::Base.connection connection.runtime += event.duration return unless logger.debug? @@ -26,10 +27,6 @@ module ActiveRecord @odd_or_even = !@odd_or_even end - def connection - ActiveRecord::Base.connection - end - def logger ActiveRecord::Base.logger end diff --git a/activerecord/lib/active_record/railties/controller_runtime.rb b/activerecord/lib/active_record/railties/controller_runtime.rb index aed1c59b00..cf74fa1655 100644 --- a/activerecord/lib/active_record/railties/controller_runtime.rb +++ b/activerecord/lib/active_record/railties/controller_runtime.rb @@ -11,9 +11,10 @@ module ActiveRecord def cleanup_view_runtime if ActiveRecord::Base.connected? - db_rt_before_render = ActiveRecord::Base.connection.reset_runtime + connection = ActiveRecord::Base.connection + db_rt_before_render = connection.reset_runtime runtime = super - db_rt_after_render = ActiveRecord::Base.connection.reset_runtime + db_rt_after_render = connection.reset_runtime self.db_runtime = db_rt_before_render + db_rt_after_render runtime - db_rt_after_render else |