aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurizio De Santis <desantis.maurizio@gmail.com>2013-02-07 22:50:17 +0100
committerMaurizio De Santis <desantis.maurizio@gmail.com>2013-02-07 22:50:17 +0100
commitcf5e0f490cf9f9c82b322263dc768176edbdc27f (patch)
tree93bd8820c8c824ac82f75b8ab7a50c93615a5524
parentba407c8f7b8ca48d9f20318d23b60b32d2cd6b9c (diff)
downloadrails-cf5e0f490cf9f9c82b322263dc768176edbdc27f.tar.gz
rails-cf5e0f490cf9f9c82b322263dc768176edbdc27f.tar.bz2
rails-cf5e0f490cf9f9c82b322263dc768176edbdc27f.zip
Add example for ActiveRecord::Base.group using a string as argument
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index c025facbb9..4e4e58b319 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -230,6 +230,9 @@ module ActiveRecord
#
# 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