# Select and options\_for\_select trouble

**URL:** <https://www.ruby-forum.com/t/select-and-options-for-select-trouble/103324>\
**Category:** Rails\
**Created:** [May 4, 2007, 10:34am UTC](https://www.ruby-forum.com/t/select-and-options-for-select-trouble/103324 "2007-05-04T10:34:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiridis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@amiridis](https://www.ruby-forum.com/u/amiridis)\
**Post date:** [May 4, 2007, 10:34am UTC](https://www.ruby-forum.com/t/select-and-options-for-select-trouble/103324/1 "2007-05-04T10:34:59Z")

</div>

Hi,

I am a newbie in Ruby and Rails. I am trying to create a drop down list  
with fixed values but the selected option should be saved in the  
database.

I have the table commands. Each command has a status which is selected  
from a fixed list. The status field in the database is an integer and  
can take the values 1, 2 and 3. My view should present the user a drop  
down list with human readable elements that correspond to each of the  
integers above. So for 1, 2 and 3 I should present the user a list with  
the following words: Pending, Completed, Canceled.

Here is what I did and the result is not what I expected:

Status  
\<%= select('command', 'status', options\_for\_select({'Pending' =\> 1, 'Completed' =\> 2, 'Canceled' =\> 3})) %\>

This makes a drop down list but the contents are the statements  
themselves!! What am I doing wrong?

Thank you,  
Petros

---

<div class="post-metadata">

**Author:** ![amiridis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/73ab20/32.png) [@amiridis](https://www.ruby-forum.com/u/amiridis)\
**Post date:** [May 4, 2007, 3:20pm UTC](https://www.ruby-forum.com/t/select-and-options-for-select-trouble/103324/2 "2007-05-04T15:20:40Z")

</div>

Petros A. wrote:

> Status  
> \<%= select('command', 'status', options\_for\_select({'Pending' =\> 1, 'Completed' =\> 2, 'Canceled' =\> 3})) %\>

Ok, I found out myself. I don’t have to use options\_for\_select:

\<%= select(‘command’, ‘status’,  
{‘Pending’ =\> 1, ‘Completed’ =\> 2, ‘Canceled’ =\> 3})

Thank you,  
Petros
