Number.find() shall only return unique values

Hi,

I got an address book with a list-column, and I want this dropdown to
display the unique values I have used. So I can sort on e.g. "work" or
"friend".

<%= select("post", "list", Number.find(:all, :order => "list",
:conditions => "company = '#{$user_company}' ").collect \
{|p| [ p.list ] }, { :include_blank => true }) %>

Is that possible, or do I have to use a low level SQL query?

Best regards,
Martin Stabenfeldt

Thanks,

With some minor syntax editing, it workes like a sharm! :slight_smile:
Thanks!

<%= select("post", "list", Number.find(:all, :select => 'DISTINCT
list', :conditions => "company = '#{$user_company}' ").collect \
    {|p| [ p.list ] }, { :include_blank => true }) %>

Rgds,
Martin Stabenfeldt

You can also use .uniq to remove duplicates at the Ruby level.

Michael