Best find for the job...

Hi all,

I'm trying to find the most effective way to generate an aggregation report. The models involved are:

Customer --(has_many)--> Charges Charges --(have_one)-->Account

What I'm trying to do is find the total charges during the year for each customer by account. In other words, a function like:

customer.charges_for_year()

in the customer model that will return a hash of each account charged and the customer's total charges to that account.

From what I've read I don't think I should be using named_scope, since this involves associations...

Any ideas?

Thanks!

In my opinion, the best way is the first way that works. If that method proves to be too inefficient, then optimize afterwards.