# {HTML options} in collection\_select that show pre-selected options?

**URL:** <https://www.ruby-forum.com/t/html-options-in-collection-select-that-show-pre-selected-options/120779>\
**Category:** Rails\
**Created:** [November 20, 2007, 3:55pm UTC](https://www.ruby-forum.com/t/html-options-in-collection-select-that-show-pre-selected-options/120779 "2007-11-20T15:55:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yachtman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/d07c76/32.png) [@yachtman](https://www.ruby-forum.com/u/yachtman)\
**Post date:** [November 20, 2007, 3:55pm UTC](https://www.ruby-forum.com/t/html-options-in-collection-select-that-show-pre-selected-options/120779/1 "2007-11-20T15:55:38Z")

</div>

Seeking rails help…

On a form that is being edited (data is pre-filled), I am trying to  
show a collection\_select with already selected options that are drawn  
from my database. I think that my code is nearly correct, but I just  
can’t seem to ‘bind’ the instance variable to the list:

\*\*\* VIEW \*\*\*  
\<%= collection\_select( :tag, :name, @tags, :id, :name,  
{}, :selected =\> @tags\_selected, :multiple =\> true, :size =\>5) %\>

\*\*\* CONTROLLER \*\*\*  
@tags\_selected = EntryTag.find(:all, :conditions =\> “entry\_id =  
#{params[:id]}”)

My form comes up fine with all of the other data, as well as the items  
in the collection\_select, but there is nothing pre-selected (there  
should be three items selected).

Thanks in advance!

yachtman
