instance method
distinct
Ruby on Rails 5.0.7.2
Since v4.0.13Signature
distinct()
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).distinct
# => [#<Pet name: "Fancy-Fancy">]
Source
# File activerecord/lib/active_record/associations/collection_proxy.rb, line 712
def distinct
@association.distinct
end
Defined in activerecord/lib/active_record/associations/collection_proxy.rb line 712
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Associations::CollectionProxy