aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorIgor <fedoronchuk@gmail.com>2013-02-08 00:54:46 +0200
committerIgor <fedoronchuk@gmail.com>2013-02-27 16:35:22 +0200
commitdd0bbd2ccb9c813902ae263dd4cc21f85af0bdc4 (patch)
tree68fb32de77f6dd70fca498fa7e21e74acf9df369 /activerecord
parentdca0b57d03deffc933763482e615c3cf0b9a1d97 (diff)
downloadrails-dd0bbd2ccb9c813902ae263dd4cc21f85af0bdc4.tar.gz
rails-dd0bbd2ccb9c813902ae263dd4cc21f85af0bdc4.tar.bz2
rails-dd0bbd2ccb9c813902ae263dd4cc21f85af0bdc4.zip
fix db_runtime attribute value after raising ActionView::MissingTemplate exception
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md8
-rw-r--r--activerecord/lib/active_record/railties/controller_runtime.rb3
2 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 55fa9cae81..bb32d16fc1 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,13 @@
## Rails 4.0.0 (unreleased) ##
+* Fix calculation of `db_runtime` property in
+ `ActiveRecord::Railties::ControllerRuntime#cleanup_view_runtime`.
+ Previously, after raising `ActionView::MissingTemplate` db_runtime was
+ not populated.
+ Fixes #9215.
+
+ *Igor Fedoronchuk*
+
* Schema dumper supports dumping the enabled database extensions to `schema.rb`
(currently only supported by postgresql).
diff --git a/activerecord/lib/active_record/railties/controller_runtime.rb b/activerecord/lib/active_record/railties/controller_runtime.rb
index 7695eacbff..af4840476c 100644
--- a/activerecord/lib/active_record/railties/controller_runtime.rb
+++ b/activerecord/lib/active_record/railties/controller_runtime.rb
@@ -21,9 +21,10 @@ module ActiveRecord
def cleanup_view_runtime
if ActiveRecord::Base.connected?
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
+ self.db_runtime = (db_runtime || 0) + db_rt_before_render
runtime = super
db_rt_after_render = ActiveRecord::LogSubscriber.reset_runtime
- self.db_runtime = db_rt_before_render + db_rt_after_render
+ self.db_runtime += db_rt_after_render
runtime - db_rt_after_render
else
super