HMT: Count Associated Items

I have a members and a projects table. They are associated via a has_many
:through. I want to find out how many members are interested in a specific
project. All I could come up with was:

a = Project.find(:first, :include => :members, :conditions =>
"'my project'").members.size

Actually, the problem is more complex than this simple example. I want to
find count of members interested in a specific project grouped by date and
filtered by a specific date range.

Is there a calculations magical way to do this or is it strictly



Check out :counter_cache at

It's also explained on the migrations screencast.

Hope that helps.

I wound up using find_by_sql:

     @signups = Member.find_by_sql(
         ["select DATE(created_on) as created_on, count(
as counter from members
             join assignments on = assignments.member_id
             join projects on = assignments.project_id
             group by week(members.created_on)", project_id]

Which gives me a weekly summary of member creation records aggregated
(counted) by week for a certain project. I'm afraid a counter cache
would not be specific enough for the problem I'm trying to solve. I
was hoping there was some natural Rails syntax in Calculations that
would get me close to this.