Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MovieSweeper < ActionController::Caching::Sweeper
- observe Movie
- # if a movie is created or deleted, movie list becomes invalid
- def after_create(movie) ; expire_action :action => 'index' ; end
- def after_destroy(movie) ; expire_action :action => 'index' ; end
- # if a movie is updated, its cached 'show' view becomes invalid
- def after_update(movie) ; expire_fragment movie_path(movie) ; end
- end
- # IMPORTANT: must add following to top of MoviesController:
- cache_sweeper :movie_sweeper
- caches_action :index, :show
Add Comment
Please, Sign In to add comment