提交 cf5e0f49 编写于 作者: M Maurizio De Santis

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

上级 ba407c8f
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册