From d7a2309fe39d3807c1c97de116b23d6bb2c08d79 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Thu, 5 Jul 2012 19:01:00 -0700 Subject: Add group documentation --- activerecord/lib/active_record/relation/query_methods.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 51d21121c8..1636e49065 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -142,6 +142,18 @@ module ActiveRecord self end + # Allows to specify a group attribute: + # + # User.group(:name) + # => SELECT "users".* FROM "users" GROUP BY name + # + # Returns an array with uniq records based on the `group` attribute: + # + # User.select([:id, :name]) + # => [#, #, # + # + # User.group(:name) + # => [#, #] def group(*args) args.blank? ? self : spawn.group!(*args) end -- cgit v1.2.3