Forum: Ruby on Rails non model select_tag problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Per D. (Guest)
on 2005-11-22 20:59
What am I doing wrong here:

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?
Deepak S. <> < (Guest)
on 2005-11-22 21:22
Try @params[:website_ids]

Alternatively I have done it like this:

<% receivers = @dealing.receivers if @dealing.receivers%>
"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.
Per D. (Guest)
on 2005-11-22 23:25
Thanks, still does not work though.

I should point out that it works with this code:
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]".
Per D. (Guest)
on 2005-11-23 01:30
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.
This topic is locked and can not be replied to.