rails expiring cache
- by ash34
Hi,
I entered some products data into a table using a migration. I need to expire the page and fragment cache when I update, add, delete products from this table. I created a sweeper for this.
class ProductSweeper < ActionController::Caching::Sweeper
observe Product
def after_create
expire_cache
end
def after_save
expire_cache
end
def after_update
expire_cache
end
def after_destroy
expire_cache
end
private
def expire_cache
expire_page(:controller => 'ProductsController', :action => 'index')
expire_fragment 'listed_products'
end
end
Then in script/console I update the product name and saved. When I reload my app in the browser it still gives me a cache hit.
Cached fragment hit: views/listed_products (0.2ms)
Can someone tell me how to expire this cache. I will not be adding, updating, deleting products through a controller action.
thanks,
ash