我只是想让一个允许选择多个值的列表框工作。它正确地传递了一组用户 ID,但传递的第一个参数为空。我在源表中没有任何空值,所以我很困惑这是从哪里来的。我可能在做一些基本的错误,所以非常感谢任何帮助。
来自日志文件:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"0Ia2kGYj1qidP6saEOfAjywDQkbds+cbFBzJ1H3UyRE=", "user_ids"=>["", "3", "4"], "commit"=>"Add Users to Group", "id"=>"create_multiple"}
`[1m[35mUser Load (1.0ms)[0m SELECT `users`.* FROM `users` WHERE `users`.`user_id` IN (0, 3, 4)`
视图代码:
<%= form_for :user, :url => create_multiple_user_roles_path, :html => { :method => :put } do |f| %>
<p>
<%= collection_select(:user, :user_ids, @users, :id, :last_name,
{ :selected => :user_ids },
{:multiple => true, :name => 'user_ids[]', :size => 10, :include_blank => false } ) %>
</p>
<%= submit_tag "Add Users to Group" %>