Reputation: 1090
I'm looking for a way to order the contents of the drop down menu I have made. At the moment, the drop down menu shows each unique client
in the database, but in the order that they were put in the database.
<%= select(@projects, :client, Project.all.map {|p| [p.client]}.uniq, :prompt => "-Any-", :selected => params[:client]) %></br>
Is there a way to show them so that they are displayed in some order?
Thanks in advance.
Upvotes: 0
Views: 965
Reputation: 1452
Did you try using .order
like this?
Project.order("name DESC").map{|p| [p.client]}
Upvotes: 3