Created
August 9, 2008 13:27
-
-
Save koshigoe/4680 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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