.distinct or .uniq
suggest changeTo drop duplicate rows from a relation, use distinct:
Customer.select(:country).distinct
The query is:
SELECT DISTINCT "customers"."country" FROM "customers"
On a relation, uniq did the same thing. It was deprecated in Rails 5.0 and removed in Rails 5.1, because it is easy to confuse with Array#uniq and with the word “unique”. distinct matches the SQL keyword. Array#uniq is unchanged.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents