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?
--
Posted via http://www.ruby-forum.com/.
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.
--
Posted via http://www.ruby-forum.com/.
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]".
--
Posted via http://www.ruby-forum.com/.
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. -- Posted via http://www.ruby-forum.com/.