saasbook

movie_sweeper.rb

Jul 11th, 2012
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.38 KB | None | 0 0
  1. class MovieSweeper < ActionController::Caching::Sweeper
  2.   observe Movie
  3.   # if a movie is created or deleted, movie list becomes invalid
  4.   #   and rendered partials become invalid
  5.   def after_save(movie)    ; invalidate ; end
  6.   def after_destroy(movie) ; invalidate ; end
  7.   private
  8.   def invalidate
  9.     expire_action :action => ['index', 'show']
  10.     expire_fragment 'movie'
  11.   end
  12. end
Add Comment
Please, Sign In to add comment