Friday, October 26, 2012

[Rails] 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/wxu_phRAvMQJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate