aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/calculations.rb
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2014-06-03 21:56:09 -0400
committereileencodes <eileencodes@gmail.com>2014-06-03 21:56:09 -0400
commit3ef8d536855075c6b7f1b15d150b701f63d1111c (patch)
tree21297842fd8900bb1a2add7d23ad315d0f803530 /activerecord/lib/active_record/relation/calculations.rb
parent489a8f2a44dc9cea09154ee1ee2557d1f037c7d4 (diff)
downloadrails-3ef8d536855075c6b7f1b15d150b701f63d1111c.tar.gz
rails-3ef8d536855075c6b7f1b15d150b701f63d1111c.tar.bz2
rails-3ef8d536855075c6b7f1b15d150b701f63d1111c.zip
reuse available belongs_to? method
Reflection has a `belongs_to?` method. Instead of checking for `macro == :belongs_to` throughout the source reuse existing method. I also bumped `foreign_key_present?` method onto on line because the `belongs_to?` makes it shorter than other longer lines in the same class.
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 9ee6422329..11ab1b4595 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -278,7 +278,7 @@ module ActiveRecord
if group_attrs.first.respond_to?(:to_sym)
association = @klass._reflect_on_association(group_attrs.first.to_sym)
- associated = group_attrs.size == 1 && association && association.macro == :belongs_to # only count belongs_to associations
+ associated = group_attrs.size == 1 && association && association.belongs_to? # only count belongs_to associations
group_fields = Array(associated ? association.foreign_key : group_attrs)
else
group_fields = group_attrs