Forum: Ruby on Rails How to set the selected option for a combo box?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6b8aa124af0fda026fc3ab9375928015?d=identicon&s=25 csaba (Guest)
on 2009-02-14 11:13
(Received via mailing list)
<div>
        <label for="category" class="label_left">Kategorie</label>
          <% @selected_category =
           Category.find(:first, :select => "name, id", :conditions =>
["id = ?",  params['category_id']]) %>
         <% @all_categories = Category.find(:all, :order =>
'id').collect {|c| ([c.name, c.id])} %>
         <select name='edition[category_id]' id='category'
class='fieldStyle'  tabindex='3'>
        <%= options_for_select(@all_categories, @selected_category.name)
%>
     </select>
  </div>
This topic is locked and can not be replied to.