Skip to content

Instantly share code, notes, and snippets.

@scott

scott/gist:61700

Created Feb 10, 2009
Embed
What would you like to do?
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