Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created December 7, 2010 06:32
Show Gist options
  • Save ahawkins/731535 to your computer and use it in GitHub Desktop.
Save ahawkins/731535 to your computer and use it in GitHub Desktop.
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