Method: ActiveRecord::QueryMethods#distinct

Defined in:
lib/active_record/relation/query_methods.rb

#distinct(value = true) ⇒ Object

Specifies whether the records should be unique or not. For example:

User.select(:name)
# Might return two records with the same name

User.select(:name).distinct
# Returns 1 record per distinct name

User.select(:name).distinct.distinct(false)
# You can also remove the uniqueness


1102
1103
1104
# File 'lib/active_record/relation/query_methods.rb', line 1102

def distinct(value = true)
  spawn.distinct!(value)
end