My view lists a set of expenses, I would like to sum the values in the current view. This is the code I am trying in my controller.
@project = Project.find(params[:project_id])
@expense_list = @project.expenses.find_all_by_user_id(current_user.id).sort_by(&:expense_date)
@expense_total = @expense_list.sum(:amount)
The error I get is:
undefined method `+' for #<Expense:0x007f907a2ba888>
Any advice? I feel like I'm doing something wrong. Thanks!