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
- # and rendered partials become invalid
- def after_save(movie) ; invalidate ; end
- def after_destroy(movie) ; invalidate ; end
- private
- def invalidate
- expire_action :action => ['index', 'show']
- expire_fragment 'movies_with_ratings'
- 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