diff options
author | Tobias Lütke <tobias.luetke@gmail.com> | 2007-02-21 18:08:39 +0000 |
---|---|---|
committer | Tobias Lütke <tobias.luetke@gmail.com> | 2007-02-21 18:08:39 +0000 |
commit | 2ffbc6115e5389642f1b1c10fa5257aef0ad3920 (patch) | |
tree | 888054c888e12e935fa4fc25187a2eac64a6a260 /actionpack | |
parent | 9b854c22b10992de25291ce1b69699618634ec72 (diff) | |
download | rails-2ffbc6115e5389642f1b1c10fa5257aef0ad3920.tar.gz rails-2ffbc6115e5389642f1b1c10fa5257aef0ad3920.tar.bz2 rails-2ffbc6115e5389642f1b1c10fa5257aef0ad3920.zip |
Enable active record cache automatically for all actions
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index c7f3e95617..d016d09baa 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -10,7 +10,8 @@ module ActionController #:nodoc: # Note: To turn off all caching and sweeping, set Base.perform_caching = false. module Caching def self.included(base) #:nodoc: - base.send(:include, Pages, Actions, Fragments, Sweeping) + base.send(:include, Pages, Actions, Fragments) + base.send(:include, Sweeping, SqlCache) if defined?(ActiveRecord) base.class_eval do @@perform_caching = true @@ -612,5 +613,20 @@ module ActionController #:nodoc: end end end + + if defined?(ActiveRecord) + module SqlCache + def self.included(base) #:nodoc: + base.alias_method_chain :perform_action, :caching + end + + def perform_action_with_caching + ActiveRecord::Base.cache do + perform_action_without_caching + end + end + end + end + end end |