title: Rails group by column and select column
body: <p>I have a table DinnerItem with columns id, name, project_id, client_id, item_id and item_quantity.</p>
  
  <p>I want to fetch data group_by item_id column and the value should only have the item_quantity column value in the format </p>
  
  <pre><code>{ item_id1 =&gt; [ {item_quantity from row1}, {item_quantity from row2}],
    item_id2 =&gt; [ {item_quantity from row3}, {item_quantity from row4} ]
  }
  </code></pre>
  
  <p>How can I achieve it in one single query?</p>
  
  <pre><code>OfferServiceModels::DinnerItem.all.select('item_id, item_quantity').group_by(&amp;:item_id)
  </code></pre>
  
  <p>But this has the format</p>
  
  <pre><code> {1=&gt;[#&lt;DinnerItem id: nil, item_id: 1, item_quantity: nil&gt;, #&lt;DinnerItem id: nil, item_id: 1, item_quantity: {"50"=&gt;30, "100"=&gt;10}&gt;], 4=&gt;[#&lt;DinnerItem id: nil, item_id: 4, item_quantity: {"100"=&gt;5, "1000"=&gt;2}&gt;}
  </code></pre>