Guest User

Untitled

a guest
Feb 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. # config/initializers/action_cache.rb
  2.  
  3. module ActionController::Caching::Actions::ClassMethods
  4.  
  5. # ex) continue filter chain
  6. #
  7. # caches_action :action_name, :continue => true
  8. #
  9. def caches_action(*actions)
  10. return unless cache_configured?
  11. options = actions.extract_options!
  12. around_filter(ActionController::Caching::Actions::ActionCacheFilter.new(:cache_path => options.delete(:cache_path), :continue => options.delete(:continue)), {:only => actions}.merge(options))
  13. end
  14.  
  15. end
  16.  
  17. class ActionController::Caching::Actions::ActionCacheFilter
  18.  
  19. alias_method :before_origin, :before
  20.  
  21. # ex) cancel action
  22. #
  23. # def action_name
  24. # if rendered_action_cache
  25. # @performed_render = true
  26. # return
  27. # end
  28. # ...
  29. # end
  30. #
  31. def before(controller)
  32. result = before_origin(controller)
  33. if result == false && @options[:continue]
  34. controller.instance_eval { @performed_render = false }
  35. return true
  36. end
  37. return result
  38. end
  39.  
  40. end
Add Comment
Please, Sign In to add comment