views:

17

answers:

1

I have a cache counter setup for a Posts class on the comments field. Posts have many comments, and a comment belongs to a post.

If I add a new comment to a post and save, the counter gets incremented, but if I delete an individual comment, the counter is not touched. Is this not provided automatically, or do I have to roll me own decrementor when working with counter_cache?

Rails 2.3.2

Thank you!

+2  A: 

How are you deleting the comment?

You should know that ActiveRecord::Base delete and destroy are not the same thing. Delete won't go through any callbacks, so it won't update the cache counter.

Jamie Wong
This is probably it. +1
thomasfedb
that did it, d'oh!
tesmar