title: How to do join with SUM in ActiveRecord
body: <p>Let's say I have two simple models</p>
  
  <pre><code>project
     t.string :title
  
  vote
     t.references :project
     t.integer :value
  </code></pre>
  
  <p>When I do loop throuh all projects, I also want to include sum of all votes, because doing</p>
  
  <pre><code>projects = Project.all
  
  foreach project in projects
      sum = project.votes.sum(:value)
      ...
  </code></pre>
  
  <p>isn't really effective.</p>
  
  <p>Is there any way how to do this without manualy writing the SQL? Something like</p>
  
  <pre><code>SELECT p.*, SUM(v.value)
  FROM projects p
  LEFT JOIN votes v
  ON v.project_id = p.id
  GROUP BY p.id
  </code></pre>