title: how to group by and sum in rails 4
body: <p>I read <a href="https://stackoverflow.com/questions/9068926/rails-3-group-by-and-sum">the following post</a> and <a href="https://stackoverflow.com/questions/2961479/rails-activerecord-friendly-code-from-a-complex-join-sum-and-group-query">this post</a> but I am still having some implementation problems.</p>
  <p>In am trying to extract all costs that belongs to a user within a certain trip and sum their values based on their type(exchange_id).
  For example, a user can add a cost of 5$ , another cost of 10$ and a third cost of 50euro. I am trying to get [15$,50euro]</p>
  <p>I have the following code <code>@trip.costs.where(user_id: current_user).group(&quot;exchange_id&quot;))</code>, but I don't know how to go from here and extract just the cost's value and sum it</p>
  <p>Thank you</p>