我有一个表单,它传递与它之前的表单相同的参数:
<%= form_tag({:controller => "workouts", :action => "random"}) do %>
<%= hidden_field_tag :workout, params[:workout] %>
<%= hidden_field_tag :time, params[:time] %>
<%= submit_tag "Get Another", :class => 'btn' %>
第一种形式工作正常,第二种形式“获取另一个”给了我can't convert Symbol into Integer
这一行的错误:
@equipment_ids = params[:workout][:equipment_ids].collect{|s| s.to_i}
传递的第一种和第二种形式的参数是:
{"utf8"=>"✓",
"authenticity_token"=>"qj/Q/YWvLKK3A3paAnEom4oTFtq44daX6dvEb8qmgtE=",
"workout"=>{"equipment_ids"=>["",
"508",
"518"]},
"time"=>"25",
"commit"=>"Get Workout"}
{"utf8"=>"✓",
"authenticity_token"=>"qj/Q/YWvLKK3A3paAnEom4oTFtq44daX6dvEb8qmgtE=",
"workout"=>"{\"equipment_ids\"=>[\"\",
\"508\",
\"518\"]}",
"time"=>"25",
"commit"=>"Get Another"}
唯一的区别是转义的反斜杠。我不确定为什么这些会导致问题?