diff options
author | Maurizio De Santis <desantis.maurizio@gmail.com> | 2013-02-07 22:50:17 +0100 |
---|---|---|
committer | Maurizio De Santis <desantis.maurizio@gmail.com> | 2013-02-07 22:50:17 +0100 |
commit | cf5e0f490cf9f9c82b322263dc768176edbdc27f (patch) | |
tree | 93bd8820c8c824ac82f75b8ab7a50c93615a5524 | |
parent | ba407c8f7b8ca48d9f20318d23b60b32d2cd6b9c (diff) | |
download | rails-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.rb | 3 |
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 |