Skip to content

Commit

Permalink
Update documentation on group method to indicate it takes an array
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
estsauver committed Mar 17, 2014
1 parent cc4c6d4 commit 6c82107
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -261,6 +261,10 @@ def select!(*fields) # :nodoc:
#
# User.group('name AS grouped_name, age')
# => [#<User id: 3, name: "Foo", age: 21, ...>, #<User id: 2, name: "Oscar", age: 21, ...>, #<User id: 5, name: "Foo", age: 23, ...>]
#
# Passing in an array of attributes to group by is also supported.
# User.select([:id, :first_name]).group(:id, :first_name).first(3)
# => [#<User id: 1, first_name: "Bill">, #<User id: 2, first_name: "Earl">, #<User id: 3, first_name: "Beto">]
def group(*args)
check_if_method_has_arguments!(:group, args)
spawn.group!(*args)
Expand Down

0 comments on commit 6c82107

Please sign in to comment.