title: Rails has_many association count child rows
body: <p>What is the &quot;rails way&quot; to efficiently grab all rows of a parent table along with a count of the number of children each row has?</p>
  <p>I don't want to use <code>counter_cache</code> as I want to run these counts based on some time conditions.</p>
  <p>The cliche blog example:
  Table of articles. Each article has 0 or more comments.</p>
  <p>I want to be able to pull how many comments each article has in the past hour, day, week.</p>
  <p>However, ideally I don't want to iterate over the list and make separate sql calls for each article nor do I want to use <code>:include</code> to prefetch all of the data and process it on the app server.</p>
  <p>I want to run one SQL statement and get one result set with all the info.</p>
  <p>I know I can hard code out the full SQL, and maybe could use a <code>.find</code> and just set the <code>:joins</code>, <code>:group</code>, and <code>:conditions</code> parameters... BUT I am wondering if there is a &quot;better&quot; way... aka &quot;The Rails Way&quot;</p>