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 ]
On 19/12/2008, at 11:48 AM, Scott Kulik wrote:
>
> 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 http://www.ruby-forum.com/.
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---