Skip to content

Commit 55c0527

Browse files
author
Francesco Rodriguez
committed
add CollectionProxy#uniq documentation
1 parent 29713d7 commit 55c0527

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

activerecord/lib/active_record/associations/collection_proxy.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,27 @@ class CollectionProxy < Relation
636636
#
637637
# Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6)
638638

639+
##
640+
# :method: uniq
641+
#
642+
# :call-seq:
643+
# uniq()
644+
#
645+
# Specifies whether the records should be unique or not.
646+
#
647+
# class Person < ActiveRecord::Base
648+
# has_many :pets
649+
# end
650+
#
651+
# person.pets.select(:name)
652+
# # => [
653+
# # #<Pet name: "Fancy-Fancy">,
654+
# # #<Pet name: "Fancy-Fancy">
655+
# # ]
656+
#
657+
# person.pets.select(:name).uniq
658+
# # => [#<Pet name: "Fancy-Fancy">]
659+
639660
##
640661
# :method: count
641662
#

0 commit comments

Comments
 (0)