From 6c821073f3eb0cb4acec8ad98fc54a25fd5fe6ce Mon Sep 17 00:00:00 2001 From: Earl St Sauver Date: Mon, 17 Mar 2014 11:28:57 -0700 Subject: [PATCH] Update documentation on group method to indicate it takes an array The group method also takes an array, however this isn't immediately clear by reading the source since it delegates this method. If you trace it back to the AREL building you can see that it does support an array. Shoutout to @betovelandia for pointing this out. --- activerecord/lib/active_record/relation/query_methods.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 3a5b3116ebaea..eff10d3575e99 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -261,6 +261,10 @@ def select!(*fields) # :nodoc: # # User.group('name AS grouped_name, age') # => [#, #, #] + # + # Passing in an array of attributes to group by is also supported. + # User.select([:id, :first_name]).group(:id, :first_name).first(3) + # => [#, #, #] def group(*args) check_if_method_has_arguments!(:group, args) spawn.group!(*args)