John Smith wrote:> I have this code:
>
> <% form_for(@repair_ticket) do |f| %>
> <p>
> <%= text_field_with_auto_complete :rp_part, :name %>
> <p>
> <b>Client</b><br />
> <select name="repair_ticket[client_id]">
> <% @clients.each do |client| %>
> <option value="<%= client.id %>"
> <%= '' selected'' if client.id ==
@repair_ticket.client_id %>>
> <%= client.name %>
> </option>
> <% end %>
> </select></p>
>
> How can I ;order => client.name all the results in the list ?
in the controller:
@clients = Client.find(:all, :order => ''name'')
in the view:
f.select :client_id, @clients.map{|c| [c.name, c.id]}
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---