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
More info:
<div>
<% cache 'listed_products' do %>
<%= render :partial => "/layouts/product", :collection => Product.listed_products %>
<% end %>
</div>
here is the partial.
<ul class="vlist">
<li>
<div class="Flt Hday">
<%=h product.name %>
</div>
<div class="Frt Hday">
<%=h product.cal_date.strftime("%b %d, %Y") %>
</div>
</li>
</ul>