consider a scenario, where you have balances in a wallet and you want to sum all of them.
Where we have a wallet model, that contains a balance column
With this simple code, we can sum all the user's balance. it can help us, to see how much total worth our company has.
Wallet.sum(:balance)
if we want to sum all the balance of current user, very easy
current_user.wallets.sum(:balance)
should return us the sum
Here I am doing a similar calculation for vote weight..