diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2014-03-29 17:08:40 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2014-03-29 17:08:40 +0530 |
commit | 3ae33961e0e88c5e66502a94af29cd4b4417758f (patch) | |
tree | d7a9e464b8269707717456799c47242e72066c17 /activerecord/lib/active_record/relation | |
parent | 86c53d510cf31b792a7e96a44535e64b3983d17a (diff) | |
parent | f8872d658e7f2bee3a18be47c01754368f22ab73 (diff) | |
download | rails-3ae33961e0e88c5e66502a94af29cd4b4417758f.tar.gz rails-3ae33961e0e88c5e66502a94af29cd4b4417758f.tar.bz2 rails-3ae33961e0e88c5e66502a94af29cd4b4417758f.zip |
Merge branch 'master' of github.com:rails/docrails
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index e41df0ea29..0213bca981 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -170,7 +170,7 @@ module ActiveRecord # Use to indicate that the given +table_names+ are referenced by an SQL string, # and should therefore be JOINed in any query rather than loaded separately. - # This method only works in conjuction with +includes+. + # This method only works in conjunction with +includes+. # See #includes for more details. # # User.includes(:posts).where("posts.name = 'foo'") @@ -263,6 +263,10 @@ module ActiveRecord # # 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, ...>] + # + # Passing in an array of attributes to group by is also supported. + # User.select([:id, :first_name]).group(:id, :first_name).first(3) + # => [#<User id: 1, first_name: "Bill">, #<User id: 2, first_name: "Earl">, #<User id: 3, first_name: "Beto">] def group(*args) check_if_method_has_arguments!(:group, args) spawn.group!(*args) |