sum decimals

I have a column “hours” which I want to sum up the decimals

Week.sum(‘hour’) => 22.5

But I want to “select by project_id” not the hole table.
Week.find_all_by_project_id(@project.id, :select => “workhour”).sum #undefined method `+’ for #<Week hour: #BigDecimal:7fd68b358400,‘0.0’,9(18)>

I cant find anything …some help would be great.

You left the argument out of the .sum (i..e, .sum('hour') on the second one)

I think that you just need this:

Week.where(project_id: @project_id).sum('hour')

-Rob

Thanks Rob… true… it works as expected…