# Correct value doesn't get selected in select

**URL:** <https://www.ruby-forum.com/t/correct-value-doesnt-get-selected-in-select/184368>\
**Category:** Rails\
**Created:** [March 1, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/correct-value-doesnt-get-selected-in-select/184368 "2010-03-01T17:07:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeonS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c77e96/32.png) [@LeonS](https://www.ruby-forum.com/u/LeonS)\
**Post date:** [March 1, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/correct-value-doesnt-get-selected-in-select/184368/1 "2010-03-01T17:07:08Z")

</div>

Hi,

I’ve got a Form with a select helper, but the value in the database  
doesn’t get selected:  
The name of the model is “special\_tip” and belongs to a  
special\_quest\_option and a special\_quest

\<% form\_for special\_tip do |f|%\>  
\<%= select(“special\_tip”, “special\_quest\_option\_id”,  
special\_quest.special\_quest\_options.all.collect {|sqo| [ sqo.text,  
sqo.id ] },{:include\_blank =\> true}) %\>  
\<%= f.submit “tip the Special Quest” %\>  
\<% end %\>

What do I’m doing wrong?  
The correct values are in the select box, but the current doesn’t get  
selected.  
Thanks

---

<div class="post-metadata">

**Author:** ![LeonS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/c77e96/32.png) [@LeonS](https://www.ruby-forum.com/u/LeonS)\
**Post date:** [March 1, 2010, 5:24pm UTC](https://www.ruby-forum.com/t/correct-value-doesnt-get-selected-in-select/184368/2 "2010-03-01T17:24:41Z")

</div>

On 1 Mar 2010, at 16:05, LeonS wrote:

> sqo.id ] },{:include\_blank =\> true}) %\>  
> \<%= f.submit “tip the Special Quest” %\>  
> \<% end %\>
> 
> What do I’m doing wrong?  
> The correct values are in the select box, but the current doesn’t get  
> selected.

You’re mixing form\_for (which doesn’t require that you have an instance  
variable containing the object) and the non form builder version of  
select (which does).

f.select(“special\_quest\_option\_id”, …)

should work better

Fred
