In ruby when you want unique elements you can do:

array = [1, 2, 3, 2, 1]
 => [1, 2, 3, 2, 1]

array.uniq
 => [1, 2, 3]

When doing the same using any database collection/table:

  Person.all.map(&:name).uniq
 => ["James", "Jhon"]

This can get really slow depending on the size of the collection. Gladly mongo has a faster solution:

  Person.distinct(:name)
 => ["James", "Jhon"]