我有一个返回这个的 POST 方法:
Request Parameters:
{"cm_test_ids"=>["1",
"8",
"9",
"10",
"11"],
"commit"=>"Create",
"authenticity_token"=>"WiBZQcZt2/Vi2RiFdFtaXnthClLsMubXe6sAhUzOPo8=",
"id"=>"1",
"cm_test_campaigns_object"=>{"cm_test_campaign_id"=>"1",
"comments"=>"",
"assigned_to_id"=>"6"}}
在我的控制器应用程序中,我得到“cm_test_ids”,例如:
@ids_selected = params[:cm_test_ids]
在这一点上我没有问题,我可以将这些 id (1,8,9,10,11) 保存在关系表中,但如果我尝试这样做:
@my_tests = CmTest.find(["id IN (?)", @ids_selected])
我收到此错误:
"Couldn't find all CmTests with IDs (0,1,8,9,10,11) (found 5 results, but was looking for 6)"
它不退出的值“0”,我打印了数组@ids_selected,但我没有看到它,我不知道为什么总是在IDs数组的第一个位置添加一个“0”,知道吗?