Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 17885

Rails: how can I get unique values from column

$
0
0

How can I get unique values from column in the table?For example, I have this Products table:

ID NAME CATEGORY1 name1 1st_cat2 name2 2nd_cat3 name3 1st_cat

Here I want to get only 2 values - 1st_cat and 2nd_cat:

<%Products.each do |p|%><%=p.category%><%end%>

Viewing all articles
Browse latest Browse all 17885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>