params中指定的參數我有一個product
模型具有多對多關聯與category
模型通過加入模型category_product
未經許可參數誤差,而在控制器
我有一個產品/ new.html.slim
=simple_form_for @product, html: { multipart: true } do |t|
= t.error_notification
div class="form-group"
= t.input :name, label: 'Nom',equired: true, input_html: { class: 'form-control' }
div class="form-group"
= t.input :description, label: 'Description', required: true, input_html: { class: 'form-control' }
div class="form-group"
= t.input :price, label: 'Prix', required: true, input_html: { class: 'form-control' }
div class="form-group"
= t.input :weight, label: 'Poids', required: true, input_html: { class: 'form-control' }
div class="form-group"
= t.association :categories, as: :check_boxes, label: "Catégories"
= t.button :submit, value: "Valider", class: "btn-success marge-bas"
,當我提出我的形式,我得到以下錯誤:
found unpermitted parameter: category_ids
儘管我ProductContro繆勒我已批准category_ids:
def product_params
params.require(:product).permit(
:category_ids,
:name,
:price,
:description,
:weight,
:picture,
:picture1,
:picture2,
:picture3,
)
end
當我檢查我的params
category_ids
被串
"category_ids"=>["1", "2", "5", ""]
數組我在做什麼錯?
它確實感謝! –