instance method
distinct
Ruby on Rails 4.1.16
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 684
def distinct
@association.distinct
end
Defined in activerecord/lib/active_record/associations/collection_proxy.rb line 684
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Associations::CollectionProxy