Created
April 12, 2011 02:23
-
-
Save cowboycoded/914801 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
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