Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created October 16, 2012 05:51
Show Gist options
  • Save satococoa/3897411 to your computer and use it in GitHub Desktop.
Save satococoa/3897411 to your computer and use it in GitHub Desktop.
class HogeSweeperObserver < ActionController::Caching::Sweeper
observe Hoge
def after_update(hoge)
expire_cache_for(hoge)
end
private
def expire_cache_for(hoge)
ActionController::Base.expire_page(
Rails.application.routes.url_helpers.url_for(
:controller => 'hoges'
:action => 'show',
:id => hoge.id,
:only_path => true)
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment