title: Rails update_all using an join and sum
body: <p>First question in here. I have two rails models one is a "Quiniela"(Prediction Table) and the other the actual "Prediction". Quiniela has many predictions and predictions belong to quinielas. Prediction has an attribute called "points" that gets updated when real game results are added system. I want to update all the Quinielas which has an attribute "qpoints" with the sum of its predictions points. Here is what I have for now, I'm afraid it may be something simple but I have a poor background in SQL statements.</p>
  
  <p>The basic idea is to update all quinielas to show the sum of all its points obtained from its predictions. Right now I'm getting an invalid grouping statement or a column does not exist. Thanks.</p>
  
  <pre><code>Quiniela.joins(:predictions).
           select('SUM(predictions.points) AS totalpts, quinielas.qpoints AS points').
           update_all('points = totalpts')
  </code></pre>