diff options
author | Zachary Scott <e@zzak.io> | 2014-06-16 12:53:37 -0700 |
---|---|---|
committer | Zachary Scott <e@zzak.io> | 2014-06-16 12:53:37 -0700 |
commit | c730ae9b7788ce58fef1b62340271b3420ce962e (patch) | |
tree | 84aa69712eb0d121188da6e80a2a2d01e606e0f8 | |
parent | 5b368010f64106f7b87a4306b41adcefa856ab67 (diff) | |
parent | ae1b42c339a80794fb6f641e9a290dbfff72138e (diff) | |
download | rails-c730ae9b7788ce58fef1b62340271b3420ce962e.tar.gz rails-c730ae9b7788ce58fef1b62340271b3420ce962e.tar.bz2 rails-c730ae9b7788ce58fef1b62340271b3420ce962e.zip |
Merge pull request #15756 from aditya-kapoor/add-api-doc-for-querying
[ci skip] add API doc for AR Group.
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 028e4d80ab..316a59e0bb 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -19,7 +19,15 @@ module ActiveRecord # # Person.group(:city).count # # => { 'Rome' => 5, 'Paris' => 3 } - # + # + # If +count+ is used with +group+ for multiple columns, it returns a Hash whose + # keys are an array containing the individual values of each column and the value + # of each key would be the +count+. + # + # Article.group(:status, :category).count + # # => {["draft", "business"]=>10, ["draft", "technology"]=>4, + # ["published", "business"]=>0, ["published", "technology"]=>2} + # # If +count+ is used with +select+, it will count the selected columns: # # Person.select(:age).count |