Created
February 10, 2009 23:53
-
-
Save scott/61700 to your computer and use it in GitHub Desktop.
This file contains 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 DocSweeper < ActionController::Caching::Sweeper | |
observe Doc | |
def after_save(doc) | |
expire_page_for(doc) | |
end | |
def after_destroy(doc) | |
expire_page_for(doc) | |
end | |
private | |
def expire_page_for(record) | |
expire_page(page_path(record.category.link, record.permalink)) | |
#Expire home page | |
expire_page(root_path) | |
#Expire related pages too | |
expire_page :controller => 'categories', :action => 'show', :id => record.category.link | |
Doc.in_category(record.category_id).each do |page| | |
expire_page(page_path(page.category.link, page.permalink)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment