aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-09-23 21:56:52 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-09-23 21:56:52 +0000
commit7d9fe04b1d87b9f346649c9385a3c95121132653 (patch)
tree4df4db318434d4c4715031e2826b21f3b51dd782 /actionpack/lib
parenta6f49d9b786bfcc049a99f843de8e4d838de1179 (diff)
downloadrails-7d9fe04b1d87b9f346649c9385a3c95121132653.tar.gz
rails-7d9fe04b1d87b9f346649c9385a3c95121132653.tar.bz2
rails-7d9fe04b1d87b9f346649c9385a3c95121132653.zip
Fixed cache_page to use the request url instead of the routing options when picking a save path (closes #8614) [josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7598 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/caching.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb
index 3e01ee12b2..e90e27c388 100644
--- a/actionpack/lib/action_controller/caching.rb
+++ b/actionpack/lib/action_controller/caching.rb
@@ -136,17 +136,20 @@ module ActionController #:nodoc:
end
# Manually cache the +content+ in the key determined by +options+. If no content is provided, the contents of response.body is used
- # If no options are provided, the current +options+ for this action is used. Example:
+ # If no options are provided, the requested url is used. Example:
# cache_page "I'm the cached content", :controller => "lists", :action => "show"
- def cache_page(content = nil, options = {})
+ def cache_page(content = nil, options = nil)
return unless perform_caching && caching_allowed
-
- if options.is_a?(Hash)
- path = url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))
- else
- path = options
+
+ path = case options
+ when Hash
+ url_for(options.merge(:only_path => true, :skip_relative_url_root => true, :format => params[:format]))
+ when String
+ options
+ else
+ request.path
end
-
+
self.class.cache_page(content || response.body, path)
end