title: rails, activerecord sum then order
body: <p>i have a Job model that belongs_to User, and User has_many jobs. I want to create an AR query that calculates the total number of work days per user, then orders in Descending order. </p>
  
  <p>I have this so far, but is giving me an error: (column "Job.id" must appear in the GROUP BY clause or be used in an aggregate function)</p>
  
  <pre><code>@work_days = Job.group(:user).order('SUM(total_days)')
  </code></pre>
  
  <p>I can't seem to get the .order method to work - is there something I am missing? Thanks in advance!</p>