aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/caching
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/caching')
-rw-r--r--actionpack/lib/action_controller/caching/pages.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/caching/pages.rb b/actionpack/lib/action_controller/caching/pages.rb
index 755f1e4e0a..7aa6ce154b 100644
--- a/actionpack/lib/action_controller/caching/pages.rb
+++ b/actionpack/lib/action_controller/caching/pages.rb
@@ -78,10 +78,18 @@ module ActionController #:nodoc:
# Caches the +actions+ using the page-caching approach that'll store the cache in a path within the page_cache_directory that
# matches the triggering url.
+ #
+ # Usage:
+ #
+ # # cache the index action
+ # caches_page :index
+ #
+ # # cache the index action except for JSON requests
+ # caches_page :index, :if => Proc.new { |c| !c.request.format.json? }
def caches_page(*actions)
return unless perform_caching
- actions = actions.map(&:to_s)
- after_filter { |c| c.cache_page if actions.include?(c.action_name) }
+ options = actions.extract_options!
+ after_filter({:only => actions}.merge(options)) { |c| c.cache_page }
end
private