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 ][ blog ][ myspace ][ facebook ]
i think i found the main issue. I think there is supposed to be an each
in there like:
def self.up
User.find(:all).each do |u|
u.update_attribute :items_count, u.items.count
end
end
the weird thing is that now the migration is taking 8 seconds so it
looks promising but the data is still not updated! if i change
u.items.count to a constant like 1 it works fine, but it's not give me
error messages and @user.items.count works in my views so i'm not sure
what's wrong!
ah well, i guess i'll take another look at it tomorrow morning. thanks
for the help so far! hopefully someone can see my silly mistake.
--
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
-~----------~----~----~----~------~----~------~--~---