Skip to content

Commit

Permalink
Add example for ActiveRecord::Base.group using a string as argument
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesantis committed Feb 7, 2013
1 parent ba407c8 commit cf5e0f4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -230,6 +230,9 @@ def select!(*fields) # :nodoc:
# #
# User.group(:name) # User.group(:name)
# => [#<User id: 3, name: "Foo", ...>, #<User id: 2, name: "Oscar", ...>] # => [#<User id: 3, name: "Foo", ...>, #<User id: 2, name: "Oscar", ...>]
#
# 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, ...>]
def group(*args) def group(*args)
args.blank? ? self : spawn.group!(*args) args.blank? ? self : spawn.group!(*args)
end end
Expand Down

0 comments on commit cf5e0f4

Please sign in to comment.