Distinct (ActiveRecord::Associations::CollectionProxy) - APIdock
Maybe your like
method distinct v5.2.3 - Show latest stable - Class: ActiveRecord::Associations::CollectionProxy distinctpublic
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">] person.pets.select(:name).distinct.distinct(false) # => [ # #<Pet name: "Fancy-Fancy">, # #<Pet name: "Fancy-Fancy"> # ] Show source # File activerecord/lib/active_record/associations/collection_proxy.rb, line 723Related methods
- Instance methods
- <<
- ==
- any?
- append
- build
- calculate
- clear
- concat
- count
- create
- create!
- delete
- delete_all
- destroy
- destroy_all
- distinct
- empty?
- fifth
- find
- first
- forty_two
- fourth
- include?
- last
- length
- load_target
- loaded?
- many?
- new
- pluck
- prepend
- proxy_association
- push
- records
- reload
- replace
- reset
- reset_scope
- scope
- second
- second_to_last
- select
- size
- take
- target
- third
- third_to_last
- Class methods
- new
- Private methods
-
exec_queries -
find_from_target? -
find_nth_from_last -
find_nth_with_limit -
null_scope?
Tag » Activerecord Unique Associations
-
Get All Unique Associations In Rails 5 - Stack Overflow
-
Active Record Associations - Ruby On Rails Guides
-
Distinct Active Records In Has_many Through Associations - Lugo Labs
-
Autosaving Associations Twice In Rails 6.0.3 Violates Uniqueness
-
Ruby On Rails Tutorial => .distinct (or .uniq)
-
ActiveRecord Associations And You - Mutually Human
-
Rails Validation: Pitfalls In Validating Uniqueness With Active Record
-
How To Use Associations And Class Names In Ruby On Rails?
-
The Trouble With `has_one` - Medium
-
ActiveRecord::Associations::ClassMethods | RailsDoc(β)
-
Rails Models Cheatsheet - Devhints
-
Sinatra Activerecord Associations
-
Rails: How To Set Unique Interchangeable Index Constraint
-
Improving Database Performance And Overcoming Common N+1 ...