Permalink
Browse files

docs, explain usage of `count` + `select`. Closes #15065. [ci skip]

  • Loading branch information...
1 parent 741abc9 commit 3023363fff502487740bd0b83a3069320551ec96 @senny senny committed May 13, 2014
Showing with 8 additions and 0 deletions.
  1. +8 −0 activerecord/lib/active_record/relation/calculations.rb
@@ -19,6 +19,14 @@ module Calculations
#
# Person.group(:city).count
# # => { 'Rome' => 5, 'Paris' => 3 }
+ #
+ # If +count+ is used with +select+, it will count the selected columns:
+ #
+ # Person.select(:age).count
+ # # => counts the number of different age values
+ #
+ # Note: not all valid +select+ expressions are valid +count+ expressions. The specifics differ
+ # between databases. In invalid cases, an error from the databsae is thrown.
def count(column_name = nil, options = {})
# TODO: Remove options argument as soon we remove support to
# activerecord-deprecated_finders.

0 comments on commit 3023363

Please sign in to comment.