instance method average

Ruby on Rails 2.2.3

Last seen in v2.3.18

Available in: v2.2.3 v2.3.18

Signature

average(column_name, options = {})

Calculates the average value on a given column. The value is returned as a float. See calculate for examples with options.

Person.average('age')

Parameters

column_name req
options opt = {}
Source
# File activerecord/lib/active_record/calculations.rb, line 54
      def average(column_name, options = {})
        calculate(:avg, column_name, options)
      end

Defined in activerecord/lib/active_record/calculations.rb line 54 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Calculations::ClassMethods

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close