Activerecord aggregates

Hi,

Model.count

works.

however,

Model.average
Model.minimum
Model.maximum
Model.calculate

gives undefined method `…’

is this due to an old rails version? (I would give it here but ‘rails
–version’ gives “rails: version unknown”)

Thanks!

On 2/3/07, Alon G. [email protected] wrote:

Model.minimum
Model.maximum
Model.calculate

gives undefined method `…’

is this due to an old rails version? (I would give it here but ‘rails
–version’ gives “rails: version unknown”)

Thanks!

Possibly. According to active record’s CHANGELOG, they’ve been in
rails since 1.14.0:


1.14.0 (March 27th, 2006)

  • Added calculations: Base.count, Base.average, Base.sum,
    Base.minimum, Base.maxmium, and the generic Base.calculate. All can be
    used with :group and :having. Calculations and statitics need no
    longer require custom SQL. #3958 [Rick O.].

If you installed it via gems, you can get versions of things from the
gem command:

gem list -l | grep ^activerecord

I’ve never seen “version unknown”, and grepping the sources of the
versions I have doesn’t reveal this string.

Thanks George.
I get “activerecord (1.11.1)” so I guess my version is not up to date
enough to be able to use these commands. I’ll update it to a later
version, wanted to do so anyway…

doing ‘gem list’ (thanks didn’t know about that) i see that i have rails
0.13.1…