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?
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]”.
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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.