Skip to content

Instantly share code, notes, and snippets.

@koshigoe
Created August 9, 2008 13:27
Show Gist options
  • Save koshigoe/4680 to your computer and use it in GitHub Desktop.
Save koshigoe/4680 to your computer and use it in GitHub Desktop.
# config/initializers/action_cache.rb
module ActionController::Caching::Actions::ClassMethods
# ex) continue filter chain
#
# caches_action :action_name, :continue => true
#
def caches_action(*actions)
return unless cache_configured?
options = actions.extract_options!
around_filter(ActionController::Caching::Actions::ActionCacheFilter.new(:cache_path => options.delete(:cache_path), :continue => options.delete(:continue)), {:only => actions}.merge(options))
end
end
class ActionController::Caching::Actions::ActionCacheFilter
alias_method :before_origin, :before
# ex) cancel action
#
# def action_name
# if rendered_action_cache
# @performed_render = true
# return
# end
# ...
# end
#
def before(controller)
result = before_origin(controller)
if result == false && @options[:continue]
controller.instance_eval { @performed_render = false }
return true
end
return result
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment