Sha256: 6e1edffce61f278d65ec244b2670900a89083bfb1e0956d4b048a0deb7eec176
Contents?: true
Size: 865 Bytes
Versions: 10
Compression:
Stored size: 865 Bytes
Contents
class FavoriteSweeper < ActionController::Caching::Sweeper observe Favorite def after_create(favorite) expire_cache_for(favorite) end def after_destroy(favorite) expire_cache_for(favorite) end private def expire_cache_for(record) #the favorite is for a post if record.favoritable_type.eql?('Post') # expire the show page expire_page :controller => 'posts', :action => 'show', :id => record.favoritable, :user_id => record.favoritable.user if Post.find_recent(:limit => 16).include?(record.favoritable) # Expire the home page expire_action :controller => 'base', :action => 'site_index' # Expire the category page for this post expire_action :controller => 'categories', :action => 'show', :id => record.favoritable.category end end end end
Version data entries
10 entries across 10 versions & 1 rubygems