0

I have a Model just like this

Name  **  Money Flow

Bob       +100
Jacky     -130
Bob       -20
Charles   +30
Jacky     +10

And I want to render it in my view as

Name  **  Money Flow

Bob       +80
Jacky     -120
Charles   +30

So I want to avoid duplication of the name, and I want to sum the flows for each name.

Do you have an idea how i can do that ? For now I'm only using a normal loop to display all:

Model.all.each do |model|
    <%= model.name %>
    <%= model.money_flow %>
<%end%>
Ananas
  • 135
  • 1
  • 10

0 Answers0