# counter\_cache doesn't work for me..

**URL:** <https://discuss.rubyonrails.org/t/counter-cache-doesnt-work-for-me/9725>\
**Category:** rubyonrails-talk\
**Created:** [March 5, 2007, 7:07pm UTC](https://discuss.rubyonrails.org/t/counter-cache-doesnt-work-for-me/9725 "2007-03-05T19:07:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_C\_Greenberg](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Andrew\_C\_Greenberg](https://discuss.rubyonrails.org/u/Andrew_C_Greenberg)\
**Post date:** [March 5, 2007, 7:07pm UTC](https://discuss.rubyonrails.org/t/counter-cache-doesnt-work-for-me/9725/1 "2007-03-05T19:07:50Z")

</div>

Check the SQL generated in the log. I'm noticing that the memory  
version of the has\_may record is not having its cache value being  
updated, even when a "parent.child.create" is executed in a 1.2.2  
rails. I'll wager your code is triggering the SQL update of the  
cache counter increment, but that the update without a reload is  
overwriting the counter cache with the pre-creation value.

I'll wager that the increment SQL was fired off, but that the old  
value of the cache got rewritten during the update. A work-around  
might be to reload the Proposal record before the update (yick!)
