# Non model select\_tag problem

**URL:** <https://www.ruby-forum.com/t/non-model-select-tag-problem/48616>\
**Category:** Rails\
**Created:** [November 22, 2005, 7:59pm UTC](https://www.ruby-forum.com/t/non-model-select-tag-problem/48616 "2005-11-22T19:59:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pernod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@pernod](https://www.ruby-forum.com/u/pernod)\
**Post date:** [November 22, 2005, 7:59pm UTC](https://www.ruby-forum.com/t/non-model-select-tag-problem/48616/1 "2005-11-22T19:59:00Z")

</div>

What am I doing wrong here:

select\_tag(‘website\_ids[]’,  
options\_from\_collection\_for\_select(Website.find\_all, ‘id’, ‘name’,  
params[:website\_ids]), {:multiple =\> true, :size =\> 5})

It works fine except that it does not display the selected options once  
the form is submitted (it submits to the same page). The  
“params[:website\_ids]” part has to be wrong somehow, right?

---

<div class="post-metadata">

**Author:** ![pernod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@pernod](https://www.ruby-forum.com/u/pernod)\
**Post date:** [November 22, 2005, 8:22pm UTC](https://www.ruby-forum.com/t/non-model-select-tag-problem/48616/2 "2005-11-22T20:22:51Z")

</div>

Try @params[:website\_ids]

Alternatively I have done it like this:

\<% receivers = @dealing.receivers if @dealing.receivers%\>  
\<%=  
select\_tag(“receivers[]”,options\_from\_collection\_for\_select(Party.find\_all,  
“id”,“name”,receivers),{:multiple =\>true})%\>

I have a multiselect receivers tag . Each Dealing class has and belongs  
to many receivers aka parties.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![pernod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@pernod](https://www.ruby-forum.com/u/pernod)\
**Post date:** [November 22, 2005, 10:25pm UTC](https://www.ruby-forum.com/t/non-model-select-tag-problem/48616/3 "2005-11-22T22:25:12Z")

</div>

Thanks, still does not work though.

I should point out that it works with this code:  
select\_tag(‘website\_ids[]’,  
options\_from\_collection\_for\_select(Website.find\_all, ‘id’, ‘name’,  
[1,3,5]), {:multiple =\> true, :size =\> 5})

The only thing different is that “params[:website\_ids]” is replaced with  
the hard coded “[1,3,5]”.

---

<div class="post-metadata">

**Author:** ![pernod](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@pernod](https://www.ruby-forum.com/u/pernod)\
**Post date:** [November 23, 2005, 12:30am UTC](https://www.ruby-forum.com/t/non-model-select-tag-problem/48616/4 "2005-11-23T00:30:46Z")

</div>

Solved it now, the problem was that the params[:website\_ids] array was  
an array of strings and not integers so I had to convert each element of  
the array to an integer using .to\_i before I could use it in the  
options\_from\_collection\_for\_select tag method.
