I’m using Rails & MySql, At the moment, my data shows like this in a view:
Customer A, 5
Customer B, 3
Customer C, 2
Customer A, 2
Customer B, 4
I want it to show like this:
Customer A, 7
Customer B, 7
Customer C, 2
Currently my .html.erb view looks like this:
<% @licenses.each do |l| %>
<tr>
<td><%= l.customer.companyname %></td>
<td><%= l.customer.licensecontact %></td>
<td><%= l.amount %></td>
</td>
</tr>
<% end %>
I’m pretty sure i need to add something after @licenses.each I’m just not sure what?
From a very little information provided by you, i think You have to use Group BY
Using Rails 3
Using Rails 2 #This will work in Rails 3 as well
EDITED
You have to fetcth the record in something like following way
Change you view to following