Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion sum decimals
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Werner  
View profile  
 More options Oct 26 2012, 11:34 am
From: Werner <webagentur.la...@googlemail.com>
Date: Fri, 26 Oct 2012 08:34:32 -0700 (PDT)
Local: Fri, Oct 26 2012 11:34 am
Subject: Re: [Rails] sum decimals

Thanks Rob.. true.. it works as expected..

Am Freitag, 26. Oktober 2012 16:53:13 UTC+2 schrieb Rob Biedenharn:

> On Oct 26, 2012, at 8:18 AM, Werner wrote:

> > 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.