Created
February 5, 2009 03:20
-
-
Save Gregg/58531 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
# To add a folder for sweepers | |
# /config/environment.rb | |
config.load_paths += %W( #{RAILS_ROOT}/app/sweepers ) | |
# The Typical Sweeper | |
# /app/sweepers/post_sweeper.rb | |
class PostSweeper < ActionController::Caching::Sweeper | |
observe Post | |
def after_save(post) | |
clear_posts_cache(post) | |
end | |
def after_destroy(post) | |
clear_posts_cache(post) | |
end | |
def clear_posts_cache(post) | |
expire_page :controller => :posts, | |
:action => :index | |
expire_page :controller => :posts, | |
:action => :show, | |
:id => post | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment