# Select form tag (selected option)

**URL:** <https://www.ruby-forum.com/t/select-form-tag-selected-option/178913>\
**Category:** Rails\
**Created:** [November 13, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/select-form-tag-selected-option/178913 "2009-11-13T13:01:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![introvert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c37758/32.png) [@introvert](https://www.ruby-forum.com/u/introvert)\
**Post date:** [November 13, 2009, 1:01pm UTC](https://www.ruby-forum.com/t/select-form-tag-selected-option/178913/1 "2009-11-13T13:01:29Z")

</div>

Hello,

I’m having problems with form select tag (it wont select the expected  
value on edit action):

\<% form\_for @review do |f| %\>

\<%= f.label :customer\_service\_rating %\>  
 \<%= f.select :customer\_service\_rating, options\_for\_select(1..5), { :include\_blank =\> true } %\>

\<% end %\>

review model has a customer\_service\_rating column which is an integer.  
If I set this value to some number betwen 1-5 it wont select it on edit.

What am I doing wrong here?

Thanks for help!

---

<div class="post-metadata">

**Author:** ![introvert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c37758/32.png) [@introvert](https://www.ruby-forum.com/u/introvert)\
**Post date:** [November 13, 2009, 6:42pm UTC](https://www.ruby-forum.com/t/select-form-tag-selected-option/178913/2 "2009-11-13T18:42:07Z")

</div>

This wont work either:

\<%=  
f.select :customer\_service\_rating, options\_for\_select(1…5), {  
:selected =\> 2 }  
%\>

---

<div class="post-metadata">

**Author:** ![introvert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c37758/32.png) [@introvert](https://www.ruby-forum.com/u/introvert)\
**Post date:** [November 14, 2009, 1:36am UTC](https://www.ruby-forum.com/t/select-form-tag-selected-option/178913/3 "2009-11-14T01:36:19Z")

</div>

Use:

\<%= f.select(:customer\_service\_rating, (1…5).to\_a) %\>

---

<div class="post-metadata">

**Author:** ![introvert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/c37758/32.png) [@introvert](https://www.ruby-forum.com/u/introvert)\
**Post date:** [November 14, 2009, 1:41am UTC](https://www.ruby-forum.com/t/select-form-tag-selected-option/178913/4 "2009-11-14T01:41:35Z")

</div>

Or, more completely:

\<%= f.select(:customer\_service\_rating, (1…5).to\_a,  
{ :include\_blank =\> true, :selected =\> 2 } ) %\>
