title: Rails 3: Inner join with associations
body: <p>I'm a bit stuck on an Active Record query problem. I'd like to do a left join instead of an inner join on a query, but the results of the <code>joins</code> method are returning only an inner join. </p>
  
  <pre><code>Entry.
    joins(:measurements =&gt; :measurement_type).
    sum(:value, :conditions =&gt; ['name = ?','Calories'])
  </code></pre>
  
  <p>The tricky part is that <code>:measurements</code> has a belongs_to relationship to <code>:measurement_type</code> which is where the name column resides. </p>
  
  <p>Right now this is returning sums only for users who have food_posts. The goal is to return sums for all users. Users who don't have a food post would have a sum of zero.</p>
  
  <p>I've tried Googling and searching other posts on here, but haven't found an answer. Any suggestions?</p>
  
  <p>Also I'm using SQLite in my development environment and Postgresql for production.</p>