diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-20 18:05:01 +0900 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-09-20 18:05:01 +0900 |
commit | 1a2e3a0431651a44ab39e0881237c182770e29ed (patch) | |
tree | 3ad8b25fb2cf734fca96bd17395ca86931dd0614 /activerecord/lib/active_record/relation/calculations.rb | |
parent | 90f99689121487328f022fd09841b62378423afe (diff) | |
download | rails-1a2e3a0431651a44ab39e0881237c182770e29ed.tar.gz rails-1a2e3a0431651a44ab39e0881237c182770e29ed.tar.bz2 rails-1a2e3a0431651a44ab39e0881237c182770e29ed.zip |
No need to call to_sym here
The hash is now string-keyed, and [_]reflect_on_association calls `to_s` on the
argument anyway.
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 90e99957f6..eaaa409636 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -19,15 +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 + # + # 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, + # # => {["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 @@ -274,7 +274,7 @@ module ActiveRecord group_attrs = group_values if group_attrs.first.respond_to?(:to_sym) - association = @klass._reflect_on_association(group_attrs.first.to_sym) + association = @klass._reflect_on_association(group_attrs.first) associated = group_attrs.size == 1 && association && association.belongs_to? # only count belongs_to associations group_fields = Array(associated ? association.foreign_key : group_attrs) else |