1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

エラー Unpermitted parameter:

Posted at
Unpermitted parameter: :phone_no. Context: { controller: OrdersController, 
action: create, request: #<ActionDispatch::Request:0x00007f5c82fcdb78>, 
params: {"authenticity_token"=>"[FILTERED]", "order_address"=>{"post_no"=>"", 
"phone_no"=>"09012345678"}, "controller"=>"orders", "action"=>"create", "item_id"=>"24"} }

もろに文章の中で教えてくれているエラーでした。
phone_no パラメータが OrdersControllercreate アクションで許可されていないことが原因。
現在の order_params メソッドで phone_no を許可する必要があるよ、と教えてくれています。

解決方法
order_params メソッド内で phone_nopermit に追加する。
以下のように order_params メソッドを修正すればOK。

orders_controller.rb
def order_params
  params.require(:order_address).permit(:post_no, phone_no).merge(
  token: params[:token]
  )
end

分かりやすいエラーで助かりました。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?