Created
December 7, 2010 06:32
-
-
Save ahawkins/731535 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module CacheHelper | |
def self.included(base) | |
base.class_eval do |klass| | |
klass.send :include, ActionController::UrlWriter | |
end | |
class << base | |
def default_url_options | |
ActionMailer::Base.default_url_options | |
end | |
end | |
end | |
def expire_fragment(key) | |
return unless ActionController::Base.perform_caching | |
Rails.cache.delete ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views) | |
end | |
def expire_action(key) | |
return unless ActionController::Base.perform_caching | |
fragment = "views/" + key.split(%r{://}).last | |
Rails.cache.delete fragment | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment