Scott,

I think you would have to:

-Find all users belonging to a company (@company.users.find(:all))
-Iterate through each user and add their bug count to a total

bug_count = 0
@company.users.find(:all).each do |user|
  bug_count = bug_count + user.bugs.size
end

If you have a large company or lots of users you may be better off
writing a custom SQL statement and letting your database do the
counting.

Evan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to