Reputation: 7043
I have a method in my Transaction model which calculates sum of data from Transactions table:
def self.total_amount
sum('amount')
end
It is displayed in the view
<%= Transaction.total_amount %>
After the data is refreshed (new transactions added) the sum stays the same. How do I make it recalculate itself?
Thanks
Upvotes: 0
Views: 252
Reputation:
Try:
def self.total_amount
lambda { sum('amount') }.call
end
Though, as touched on in the comments, I have no idea why you're experiencing such behaviour. I've checked in a production environment and I receive no such problem.
Upvotes: 1