# Counter\_cache and updates

**URL:** <https://www.ruby-forum.com/t/counter-cache-and-updates/57567>\
**Category:** Rails\
**Created:** [April 12, 2006, 2:06am UTC](https://www.ruby-forum.com/t/counter-cache-and-updates/57567 "2006-04-12T02:06:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![etlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@etlund](https://www.ruby-forum.com/u/etlund)\
**Post date:** [April 12, 2006, 2:06am UTC](https://www.ruby-forum.com/t/counter-cache-and-updates/57567/1 "2006-04-12T02:06:59Z")

</div>

I’m trying to figure out how to use counter\_cache.

I’ve got Clients that have many Profiles. And I got things working so  
that  
when I add a new Profile, the profiles\_count gets updated.

profile = client.profiles.new(params[:profile])  
profile.save

However, I’m stuck trying to figure out how to deal with UPDATING a  
profile  
(moving it to a different Client). If I change the profile to a new  
client,  
I can get the right profiles\_count on the NEW client, but the OLD client  
is  
not updated (to reflect one fewer profile)

Anyone have any suggestion? I’ve been surprised at how little  
information  
I’ve found about using couter\_cache. Any good, thorough tutorials out  
there?

Thanks,

## Eric

View this message in context:  
[http://www.nabble.com/counter\_cache-and-updates-t1435328.html#a3873241](http://www.nabble.com/counter_cache-and-updates-t1435328.html#a3873241)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).
