Scott Kulik wrote:
> Scott Kulik wrote:
>> Sazima wrote:
>>> Maybe s.items.count is zero?
>>>
>>> Cheers, Sazima
>>>
>>> On Dec 19, 5:01�am, Scott Kulik <[email protected]>
>>
>> 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 not using a migration?
>
> i tried to create a rake task but that didn't work. here is my rake
> task:
>
> sku...@kuliksco-ub:/u1/app/wldev/lib/tasks$ cat update_items_count.rake
> task :updateItemsCount do
> User.find(:all) do |u|
> u.update_attribute :items_count, s.items.count
> end
> end
>
> sku...@kuliksco-ub:/u1/app/wldev/lib/tasks$ rake updateItemsCount
> (in /u1/app/wldev)
> rake aborted!
> uninitialized constant User
>
> (See full trace by running task with --trace)
>
> thanks!
got it. i had to do this:
task(:updateItemsCount => :environment) do
User.find(:all).each do |u|
u.update_attribute :items_count, u.items.count
end
end
it's still not working but at least i can test easier!
--
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
-~----------~----~----~----~------~----~------~--~---