# How to set the selected option for a combo box?

**URL:** <https://www.ruby-forum.com/t/how-to-set-the-selected-option-for-a-combo-box/160319>\
**Category:** Rails\
**Created:** [February 14, 2009, 11:13am UTC](https://www.ruby-forum.com/t/how-to-set-the-selected-option-for-a-combo-box/160319 "2009-02-14T11:13:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![csaba](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3be4f8/32.png) [@csaba](https://www.ruby-forum.com/u/csaba)\
**Post date:** [February 14, 2009, 11:13am UTC](https://www.ruby-forum.com/t/how-to-set-the-selected-option-for-a-combo-box/160319/1 "2009-02-14T11:13:31Z")

</div>

Kategorie \<% @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])} %\> \<%= options\_for\_select(@all\_categories, @selected\_category.name) %\>
