- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
def sum_all_orders
sum = 0
Order.where(user_id: self.id).each do |order|
sum = sum + order.total_sum
end
sum
end
# вместо
def sum_all_orders
orders.sum(&:total_sum)
end