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", ""]
数组我在做什么错?
它确实感谢! –