title: The easiest way in Rails to find the project with the most user tasks
body: <p>I'm still pretty green when it comes to Rails and I'm trying to create a scope or class method to help me get the "Most active project" in my timetracking app where:</p>
  
  <p>A task belongs to project and user.</p>
  
  <p>I can access user.tasks and project.tasks as well as finding out the number of hours on each project using the class method on project.rb</p>
  
  <pre><code>def project_hours
    tasks.sum(:hours)
  end
  </code></pre>
  
  <p>Ideally I'd like to be able to perform a query to get all tasks that were performed for project A by user B</p>
  
  <p>and then as a follow up, try and order projects by the amount of task hours for this project by this user.</p>
  
  <p>I apologise if this has been covered before, I'm not sure if there is an effective way of achieving this?</p>
  
  <p>Many thanks.</p>