Skip to content
This repository
Browse code

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

  • Loading branch information...
commit cf5e0f490cf9f9c82b322263dc768176edbdc27f 1 parent ba407c8
Maurizio De Santis mdesantis authored
3  activerecord/lib/active_record/relation/query_methods.rb
@@ -230,6 +230,9 @@ def select!(*fields) # :nodoc:
230 230 #
231 231 # User.group(:name)
232 232 # => [#<User id: 3, name: "Foo", ...>, #<User id: 2, name: "Oscar", ...>]
  233 + #
  234 + # User.group('name AS grouped_name, age')
  235 + # => [#<User id: 3, name: "Foo", age: 21, ...>, #<User id: 2, name: "Oscar", age: 21, ...>, #<User id: 5, name: "Foo", age: 23, ...>]
233 236 def group(*args)
234 237 args.blank? ? self : spawn.group!(*args)
235 238 end

0 comments on commit cf5e0f4

Please sign in to comment.
Something went wrong with that request. Please try again.