From 2ffbc6115e5389642f1b1c10fa5257aef0ad3920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20L=C3=BCtke?= Date: Wed, 21 Feb 2007 18:08:39 +0000 Subject: Enable active record cache automatically for all actions git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6189 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/caching.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') 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 -- cgit v1.2.3