Let's say I have the following association:
Club has_many users User has_many guns Gun has_many bullets Club: Moe, Larry, Curly Moe: 2 guns gun 1 has 100 bullets gun 2 has 20 bullets Larry: 1 gun gun 1 has 40 bullets Curly: 2 guns gun 1 has 20 bullets gun 2 has 10 bullets
Now, I want to find out how many bullets in the CLUB.
It's easy to use: Moe.bullets.sum(:amount) = 120 bullets.
But how can I get all of the bullets without iterating through each user?
Hope that makes sense.
BTW, I am using ActiveRecord and Rails 3.
Thanks!