0
我張貼這些PARAMS形式:不能得到params.permit工作
{"utf8"=>"✓", "authenticity_token"=>"XXXXX", "bike_part_id"=>["367", "368"],
"commit"=>"registrer en [48/1854]
"controller"=>"services", "action"=>"create", "bike_id"=>"10"}
這是控制器代碼:
def create
@service = Service.new(service_params)
@service.bike = @bike
@service.bike_parts = @bike_parts
respond_to do |format|
if @service.save!
#[cut..]
end
-
def service_params
params.permit(:description, :log, :due_date, :bike_id,
:user_id, :completed, :bike_part_id
)
end
但我不斷收到這個日誌:
Unpermitted parameters: utf8, authenticity_token, bike_part_id, commit
爲什麼不允許bike_part_id?
你可以發表你的表格代碼嗎? – hoangdd