我看过其他报道的参数数量错误"报告并尝试了建议但无济于事。任何帮助将不胜感激。
我收到错误"错误的参数数量(3为1)"在这一行:
params.require(:bartroute_id, bartstation_id,:bart_route_station_sequence).permit(:bartroute_id,
:bartstation_id,:bart_route_station_sequence)
这是控制器逻辑:
# Create a new route station association
def create
binding.pry
@bartroutestation = Bartroutestation.new(bartroutestation_params)
if @bartroutestation.save
flash[:success] = "Route station created"
redirect_to bartroutes_path
else
flash[:error] = "Unable to save route station. Please try again"
render :create
end
end
private
def bartroutestation_params
params.require(:bartroute_id, :bartstation_id,:bart_route_station_sequence).permit(:bartroute_id,
:bartstation_id,:bart_route_station_sequence)
end
端
以及这里的内容:
=> {"utf8"=>"✓",
"authenticity_token"=>"PToySCDEDfspMcG20//iwk+c+CqXOr5U3PkGFKujpYo=",
"bartroute_id"=>"1",
"bartstation_id"=>"1",
"bart_route_station_sequence"=>"1",
"button"=>"",
"action"=>"create",
"controller"=>"bartroutestations"}
我有其他工作控制器遵循相同的模式,他们在params中没有任何问题,我不知道与这个有什么不同。
提前感谢您提供任何帮助,您可以给新手。
答案 0 :(得分:2)
由于您的参数未嵌套,因此应该只是
def bartroutestation_params
params.permit(:bartroute_id,:bartstation_id,:bart_route_station_sequence)
end
一些文档here