title: ROR Associations group by query
body: <p>I have the following 3 models and relationship between them:</p>
  
  <pre><code>class Calendar &lt; ActiveRecord::Base 
     has_many:fiscalcalendars
    has_many:voucherdatas ,:through =&gt; :fiscalcalendars
  end
  
  class Fiscalcalendar &lt; ActiveRecord::Base
    belongs_to :calendar
    has_many :voucherdatas
  end
  
  class Voucherdata &lt; ActiveRecord::Base
     has_many   :fiscalcalendars
    has_many   :calendars, :through =&gt; :fiscalcalendars
  end
  </code></pre>
  
  <ul>
  <li>fields in calendar  : id,monthname</li>
  <li>fields in fiscalcalendar :id, calendar_id,fiscalyearweek</li>
  <li>fields in voucherdata   :id, vhour, fiscalyear week</li>
  </ul>
  
  <p>I want the sum of the vhour  for each month</p>
  
  <p>I can get it to group by fiscal week  by doing</p>
  
  <pre><code>Voucherdata.sum(:vhour,:group=&gt;:fiscalyearweek)
  </code></pre>
  
  <p>is there a simpler way to get it by month?</p>