diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-27 11:47:24 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-02-27 11:47:24 -0300 |
commit | 02037c3ea0614103793137aab932060d2123537c (patch) | |
tree | 66805a4a71367992e30265fc62a0b21faf069f0b /activerecord | |
parent | ab876893cfb77dcd760b34628a1a1152c9a448d8 (diff) | |
parent | dd0bbd2ccb9c813902ae263dd4cc21f85af0bdc4 (diff) | |
download | rails-02037c3ea0614103793137aab932060d2123537c.tar.gz rails-02037c3ea0614103793137aab932060d2123537c.tar.bz2 rails-02037c3ea0614103793137aab932060d2123537c.zip |
Merge pull request #9218 from Fivell/master
Fix calculation of db_runtime property in
ActiveRecord::Railties::ControllerRuntime#cleanup_view_runtime.
Previously, after raising ActionView::MissingTemplate, db_runtime was
not populated.
Closes #9218, Fixes #9215.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/railties/controller_runtime.rb | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 44f3115add..4a5a2d17af 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* + * Do not try to touch invalid (and thus not persisted) parent record for a `belongs_to :parent, touch: true` association 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 |