Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add example for ActiveRecord::Base.group using a string as argument

  • Loading branch information...
commit cf5e0f490cf9f9c82b322263dc768176edbdc27f 1 parent ba407c8
@mdesantis mdesantis authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  activerecord/lib/active_record/relation/query_methods.rb
View
3  activerecord/lib/active_record/relation/query_methods.rb
@@ -230,6 +230,9 @@ def select!(*fields) # :nodoc:
#
# User.group(:name)
# => [#<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)
args.blank? ? self : spawn.group!(*args)
end
Please sign in to comment.
Something went wrong with that request. Please try again.