I have a form in which people can select a date, and click "filter". This date is then passed back to the controller as a parameter, and the view is reloaded with a list of users named @users
I then have a form that I want to pass the @users back as an array
I tried this
= form_tag('/complete_export', :method => "put", :id => 'export') do |f|
%p=hidden_field_tag "users", "#{@users.map(&:id)}"
%p=submit_tag("Export results »")
But when it gets back to the controller, the parameter arrives back looking like this...
[8] pry(#<AccountsController>)> params[:users]
"[53533, 51780, 17418, 153, 50667, 141, 48968, 48343, 48338, 47377, 44736, 40410, 27878, 172, 150, 34457, 37757, 26715, 31240, 31178, 30016, 184, 177, 196, 193, 155, 170]"
so it's actually coming back as a string. How do I pass it to the controller as an array, or change it in the controller into an array.
EDIT
So I have now amended my form as such...
= form_tag('/complete_export', :method => "get", :id => 'export') do |f|
- @users.each do |user|
=hidden_field_tag :user_ids, :multiple => true, :value => user.id
%p=submit_tag("Export results »")
Back in the controller, the params are showing as...
"utf8" => "✓",
"employee_ids" => "{:multiple=>true, :value=>170}",
"commit" => "Export results »",
"action" => "complete_payrite_export",
"controller" => "accounts"
clearly I'm missing something :(
_tagsufix, and that doesn't allow you to pass themultipleoption.