以下代码应该创建一个数组并将其作为参数哈希的一部分发送:
it "should create an outing" do
lambda do
post :create, { :outing => FactoryGirl.attributes_for(:outing), :guestvalue => ["80","89"] , :barvalue => ["2976","2973"] }
end.should change(Outing, :count).by(1)
end
相反,它给了我错误:
NoMethodError:
undefined method `[]' for nil:NilClass
参数被传递到我的控制器的这一部分:
params[:guestvalue].each do |guest_id|
@outing.add_guest(guest_id)
end
params[:barvalue].each do |bar_id|
@outing.add_bar(bar_id)
end