Currently I'm performing some calculations in my views, which is a bad thing, of course:
<% categories.each do |c| %>
....
<%= c.transactions.sum("amount_cents") %>
....
<% end %>
I am researching ways that will help me to refactor the above issue.
One thing is to move the calculation to my controller
@category_sum = @transaction.sum("amount_cents")
Which is probably a better solution, but you know. Not perfect.
Since I have many users, I do not see how can I move the calculator logic into my Model. So I guess I might need to use a new Class, create a bunch of methods (sum, average, etc.) and use them in the views? Am I on the right track? Will be thankful for any advice on how to restructure my code and design and implement this Class.