aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-26 22:43:24 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-05-26 22:43:24 -0500
commit55c05276c71548f158cb9ae28fe2a154de9f8349 (patch)
treecf560fe427d043dbc6911228db3eca1cbbd3d72e
parent29713d7f3bca4267343a0bcaf8f1ee0ea3fe02ae (diff)
downloadrails-55c05276c71548f158cb9ae28fe2a154de9f8349.tar.gz
rails-55c05276c71548f158cb9ae28fe2a154de9f8349.tar.bz2
rails-55c05276c71548f158cb9ae28fe2a154de9f8349.zip
add CollectionProxy#uniq documentation
-rw-r--r--activerecord/lib/active_record/associations/collection_proxy.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb
index 7408428493..294aa63f75 100644
--- a/activerecord/lib/active_record/associations/collection_proxy.rb
+++ b/activerecord/lib/active_record/associations/collection_proxy.rb
@@ -637,6 +637,27 @@ module ActiveRecord
# Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6)
##
+ # :method: uniq
+ #
+ # :call-seq:
+ # uniq()
+ #
+ # Specifies whether the records should be unique or not.
+ #
+ # class Person < ActiveRecord::Base
+ # has_many :pets
+ # end
+ #
+ # person.pets.select(:name)
+ # # => [
+ # # #<Pet name: "Fancy-Fancy">,
+ # # #<Pet name: "Fancy-Fancy">
+ # # ]
+ #
+ # person.pets.select(:name).uniq
+ # # => [#<Pet name: "Fancy-Fancy">]
+
+ ##
# :method: count
#
# :call-seq: