# Counter\_cache bug not resolved?

**URL:** <https://www.ruby-forum.com/t/counter-cache-bug-not-resolved/126092>\
**Category:** Rails\
**Created:** [January 15, 2008, 11:52am UTC](https://www.ruby-forum.com/t/counter-cache-bug-not-resolved/126092 "2008-01-15T11:52:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeanmartin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/46a35a/32.png) [@jeanmartin](https://www.ruby-forum.com/u/jeanmartin)\
**Post date:** [January 15, 2008, 11:52am UTC](https://www.ruby-forum.com/t/counter-cache-bug-not-resolved/126092/1 "2008-01-15T11:52:32Z")

</div>

I’ve already filed a bug: [http://dev.rubyonrails.org/ticket/10804](http://dev.rubyonrails.org/ticket/10804)  
I’m still not sure if i’m missing something.

When I update a child by setting the association method to nil, the  
counter of the parent does not get decremented. For a code example see  
the first answer to my ticket.

The problem seems to be that the @owner variable in  
activerecord/lib/active\_record/associations/belongs\_to\_association.rb  
holds the child object, not the parent. That’s why it cant have the  
counter\_cache\_column and the test:  
if @owner[counter\_cache\_name] and not @owner.new\_record?  
fails.

I really would appreciate anyone who gives this a try with his  
installation and reports the results.  
The original bug (and a patch) about this issue has been posted about  
2 years ago!

\_jeanmartin

---

<div class="post-metadata">

**Author:** ![jeanmartin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/46a35a/32.png) [@jeanmartin](https://www.ruby-forum.com/u/jeanmartin)\
**Post date:** [January 15, 2008, 12:23pm UTC](https://www.ruby-forum.com/t/counter-cache-bug-not-resolved/126092/2 "2008-01-15T12:23:44Z")

</div>

On 15 Jan 2008, at 10:51, jeanmartin wrote:

> I’ve already filed a bug: [http://dev.rubyonrails.org/ticket/10804](http://dev.rubyonrails.org/ticket/10804)  
> I’m still not sure if i’m missing something.

You may have better luck discussing this on the rails-core mailing  
list, or in #rails-contrib

Fred

---

<div class="post-metadata">

**Author:** ![jeanmartin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/46a35a/32.png) [@jeanmartin](https://www.ruby-forum.com/u/jeanmartin)\
**Post date:** [January 15, 2008, 12:44pm UTC](https://www.ruby-forum.com/t/counter-cache-bug-not-resolved/126092/3 "2008-01-15T12:44:57Z")

</div>

On Jan 15, 12:23 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You may have better luck discussing this on the rails-core mailing  
> list, or in #rails-contrib

You may be right, to anyone who cares:  
[http://groups.google.com/group/rubyonrails-core/t/9e699ecde0813b13](http://groups.google.com/group/rubyonrails-core/t/9e699ecde0813b13)
