Skip to content

Instantly share code, notes, and snippets.

@cowboycoded
Created April 12, 2011 02:23
Show Gist options
  • Save cowboycoded/914801 to your computer and use it in GitHub Desktop.
Save cowboycoded/914801 to your computer and use it in GitHub Desktop.
class WidgetSweeper < ActionController::Caching::Sweeper
observe Widget
def after_update(widget)
expire_cache_for(widget)
end
def after_destroy(widget)
expire_cache_for(widget)
end
def after_create(widget)
expire_cache_for(widget)
end
private
def expire_cache_for(widget)
expire_action(:controller=>"widgets",:action=>"show",:id=>widget.id)
expire_action(:controller=>"widgets",:action=>"index")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment