[Rails] Re: help with counter_cache

2008-12-20 Thread Scott Kulik
Scott Kulik wrote: Scott Kulik wrote: Scott Kulik wrote: Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user.

[Rails] Re: help with counter_cache

2008-12-19 Thread Sazima
Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01 am, Scott Kulik rails-mailing-l...@andreas-s.net wrote: Bryce Roney wrote: You can run a migration like this def self.up    User.find(:all) do |u|      u.update_attribute :items_count, s.items.count    end end That

[Rails] Re: help with counter_cache

2008-12-19 Thread Scott Kulik
Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user. -- Posted via http://www.ruby-forum.com/.

[Rails] Re: help with counter_cache

2008-12-19 Thread Scott Kulik
Scott Kulik wrote: Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user. is there another i can do it like this but

[Rails] Re: help with counter_cache

2008-12-19 Thread Scott Kulik
Scott Kulik wrote: Scott Kulik wrote: Sazima wrote: Maybe s.items.count is zero? Cheers, Sazima On Dec 19, 5:01�am, Scott Kulik rails-mailing-l...@andreas-s.net hmm...it shouldn't be since @user.items.count in my view shows the count correctly for each user. is there another i

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
bah...i figured it out. i didn't have a default value of 0 set in the field so it wasn't updating. now it's working! the only thing now is that i have a couple thousand users who have 0 for the count values. what do you think is the best way i can mass update this field? -- Posted via

[Rails] Re: help with counter_cache

2008-12-18 Thread Bryce Roney
You can run a migration like this def self.up User.find(:all) do |u| u.update_attribute :items_count, s.items.count end end That will go through all your users and update the items_count field for all of them. ~~~ Bryce Roney [ twitter ][ blog ][ myspace ][ facebook ]

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
Bryce Roney wrote: You can run a migration like this def self.up User.find(:all) do |u| u.update_attribute :items_count, s.items.count end end That will go through all your users and update the items_count field for all of them. ~~~ Bryce Roney [ twitter ][

[Rails] Re: help with counter_cache

2008-12-18 Thread Bryce Roney
Oh sorry! I was copying the code out of a project I had. change s.items.count to u.items.count -- Bryce Roney On 19/12/2008, at 12:13 PM, Scott Kulik wrote: Bryce Roney wrote: You can run a migration like this def self.up User.find(:all) do |u| u.update_attribute :items_count,

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
Bryce Roney wrote: Oh sorry! I was copying the code out of a project I had. change s.items.count to u.items.count -- Bryce Roney np! i just tried it with the new code and it says its successful again but items_count is still showing 0. i checked @user.items.count in one of my views

[Rails] Re: help with counter_cache

2008-12-18 Thread Scott Kulik
Bryce Roney wrote: You can run a migration like this def self.up User.find(:all) do |u| u.update_attribute :items_count, s.items.count end end That will go through all your users and update the items_count field for all of them. ~~~ Bryce Roney [ twitter ][