title: Hash with 'nil' value when using `group` and `count` in query
body: <p>In Rails, I get a hash using includes: </p>
  
  <pre><code>&lt;% @teste = UserProfile.includes(:mobile_models).group(:name).count  %&gt;
  </code></pre>
  
  <p>The problem is that includes generates a hash like the following:</p>
  
  <pre><code>{nil=&gt;4774, "2610"=&gt;7, "2626"=&gt;4, "2630"=&gt;5, "2760"=&gt;4, "3250"=&gt;3, "355"=&gt;5, "3I607 BlackJack"=&gt;5, "5230"=&gt;13, "5235"=&gt;4, "5310"=&gt;5, "5500"=&gt;5, "5800 Xpress Music"=&gt;16, "6020"=&gt;4, "6120c"=&gt;4, "6131"=&gt;4, "7210"=&gt;5, "A1200r"=&gt;5, "A1900"=&gt;5, "AIKO 70"=&gt;5, "B3410W Ch@t"=&gt;4, "beTouch E100"=&gt;4, "BlackBerry 8320 (Curve)"=&gt;10,....
  </code></pre>
  
  <p>In my database, I don't find any mobile record with the name "nil". Checking my database, I can't find what might be producing this nil.</p>
  
  <p>The other goal is to sum all values, like this:</p>
  
  <pre><code> &lt;%= sum = @teste.values.sum %&gt;
  </code></pre>
  
  <p>But when I do this, the 'nil' is added too.</p>
  
  <p>---Update</p>
  
  <p>models/UserProfile</p>
  
  <pre><code>class UserProfile &lt; ActiveRecord::Base
    has_and_belongs_to_many :mobile_models, join_table: 'user_profiles_mobile_models', order: 'name'
  </code></pre>
  
  <p>models/MobileModel</p>
  
  <pre><code>class MobileModel &lt; ActiveRecord::Base
    belongs_to :mobile_maker
  </code></pre>