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 | |
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')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 14 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/predicate_builder.rb | 4 |
2 files changed, 9 insertions, 9 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 diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb index eff5c8f09c..3df0df40ee 100644 --- a/activerecord/lib/active_record/relation/predicate_builder.rb +++ b/activerecord/lib/active_record/relation/predicate_builder.rb @@ -26,7 +26,7 @@ module ActiveRecord queries << '1=0' else table = Arel::Table.new(column, default_table.engine) - association = klass._reflect_on_association(column.to_sym) + association = klass._reflect_on_association(column) value.each do |k, v| queries.concat expand(association && association.klass, table, k, v) @@ -55,7 +55,7 @@ module ActiveRecord # # For polymorphic relationships, find the foreign key and type: # PriceEstimate.where(estimate_of: treasure) - if klass && reflection = klass._reflect_on_association(column.to_sym) + if klass && reflection = klass._reflect_on_association(column) if reflection.polymorphic? && base_class = polymorphic_base_class_from_value(value) queries << build(table[reflection.foreign_type], base_class) end |