我在尝试将一个支架与两个常驻和通信复选框链接时遇到问题,如果选择了多个支架,它们似乎是分开存储的。
如果我有一个支架,参数似乎以正确的方式存储在数组的散列中,但是一旦我将另一个支架添加到同一个数组中,它似乎会交换散列。我的视图是这样的。您还可以选择添加另一个调用相同部分的支架,即:
- unless @stands.empty? %tr#show_stands.contentText %td{:width => "27%", :valign => "top"} Select Stand For Ownership %td{:width => "15%", :valign => "top"} = collection_select "owned_stands[]", "stand_id", @stands, :id, :erf_no_rr_no, options ={:prompt =>"Please select stand..."}, {:class => 'dropdownSelect'} %td{:valign => "top"} = check_box_tag "owned_stands[][owner_comm_list]" Add to Owners Communication list = check_box_tag "owned_stands[][resident_comm_list]" Add to Residents Communication list
我期待一个包含两个或更多散列的数组,具体取决于我选择的支架数量。如果我选择了一个立场和两个复选框,我希望散列谎言:
([{"stand_id" => "1", "resident_comm_list" => "1", "owner_comm_list" => "1"}])
如果我有两个,我期望:
([{"stand_id" => "1", "resident_comm_list" => "1", "owner_comm_list" => "1"},{"stand_id" => "2", "resident_comm_list" => "1", "owner_comm_list" => "1"}])
但现在如果我选择两个展位,我会发现:
([{"stand_id" => "1", "resident_comm_list" => "1"}, {"owner_comm_list" => "1"},{"stand_id" => "2"},{"resident_comm_list" => "1", "owner_comm_list" => "1"}])
当我必须遍历散列来选择stand_id时,它在我的控制器内部给了我错误。