diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-12 09:55:32 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2010-12-12 09:55:32 +0000 |
commit | 9a98c766e045aebc2ef6d5b716936b73407f095d (patch) | |
tree | 899834482c828f31a89ebc7bb6e19cbe0b5f18d3 /actionpack/lib/action_controller/caching/pages.rb | |
parent | 3a7f43ca6ecf1735e1a82d4a68ac8f62b5cf2fcf (diff) | |
parent | 307443972c5f6de959a5401eec76ca327484b10c (diff) | |
download | rails-9a98c766e045aebc2ef6d5b716936b73407f095d.tar.gz rails-9a98c766e045aebc2ef6d5b716936b73407f095d.tar.bz2 rails-9a98c766e045aebc2ef6d5b716936b73407f095d.zip |
Merge branch 'master' into nested_has_many_through
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
activerecord/lib/active_record/associations/has_many_through_association.rb
Diffstat (limited to 'actionpack/lib/action_controller/caching/pages.rb')
-rw-r--r-- | actionpack/lib/action_controller/caching/pages.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb index 104157d0b1..3e57d2c236 100644 --- a/actionpack/lib/action_controller/caching/pages.rb +++ b/actionpack/lib/action_controller/caching/pages.rb @@ -70,9 +70,9 @@ module ActionController #:nodoc: # Manually cache the +content+ in the key determined by +path+. Example: # cache_page "I'm the cached content", "/lists/show" - def cache_page(content, path) + def cache_page(content, path, extension = nil) return unless perform_caching - path = page_cache_path(path) + path = page_cache_path(path, extension) instrument_page_cache :write_page, path do FileUtils.makedirs(File.dirname(path)) @@ -97,14 +97,16 @@ module ActionController #:nodoc: end private - def page_cache_file(path) + def page_cache_file(path, extension) name = (path.empty? || path == "/") ? "/index" : URI.parser.unescape(path.chomp('/')) - name << page_cache_extension unless (name.split('/').last || name).include? '.' + unless (name.split('/').last || name).include? '.' + name << (extension || self.page_cache_extension) + end return name end - def page_cache_path(path) - page_cache_directory + page_cache_file(path) + def page_cache_path(path, extension = nil) + page_cache_directory + page_cache_file(path, extension) end def instrument_page_cache(name, path) @@ -145,7 +147,11 @@ module ActionController #:nodoc: request.path end - self.class.cache_page(content || response.body, path) + if (type = Mime::LOOKUP[self.content_type]) && (type_symbol = type.symbol).present? + extension = ".#{type_symbol}" + end + + self.class.cache_page(content || response.body, path, extension) end end |