From d3b5db8919c61243c45ebd09254de20f4aa0cf1d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 27 May 2007 16:38:02 +0000 Subject: Added custom path cache_page/expire_page parameters in addition to the options hashes [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6868 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/caching.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index ddb36c5b8e..f77cf207f5 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -118,12 +118,17 @@ module ActionController #:nodoc: # expire_page :controller => "lists", :action => "show" def expire_page(options = {}) return unless perform_caching - if options[:action].is_a?(Array) - options[:action].dup.each do |action| - self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :action => action))) + + if options.is_a?(Hash) + if options[:action].is_a?(Array) + options[:action].dup.each do |action| + self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :action => action))) + end + else + self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true))) end else - self.class.expire_page(url_for(options.merge(:only_path => true, :skip_relative_url_root => true))) + self.class.expire_page(options) end end @@ -132,7 +137,14 @@ module ActionController #:nodoc: # cache_page "I'm the cached content", :controller => "lists", :action => "show" def cache_page(content = nil, options = {}) return unless perform_caching && caching_allowed - self.class.cache_page(content || response.body, url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))) + + if options.is_a?(Hash) + path = url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format])) + else + path = options + end + + self.class.cache_page(content || response.body, path) end private -- cgit v1.2.3