0
我有一個app/views/shared/stage_items/_destroy.html.erb
部分,看起來像下面這樣:爲什麼不是name:屬性使它成爲Params中的#destroy動作?
<%= link_to 'Remove', stage_item_path(stage_item), name: "request_origin[#{controller.controller_name}]", method: :delete %>
我期待找到在PARAMS "request_origin"
當它擊中StageItems#destroy
行動。我設置了binding.pry
那裏p
編出params
但它不存在:
[2] pry(#<StageItemsController>)> pp params
{"_method"=>"delete",
"authenticity_token"=>
"1UaOESQFsvDwkZ5QQReS91UVmacmM8FpsV5O+mSoEwPRiS2JvfTNPCLDJlPSjo1XLwSGR5gWtj9IqoNIAp/Z9A==",
"controller"=>"stage_items",
"action"=>"destroy",
"id"=>"8"}
我看着呈現的HTML和name
屬性有:
<a name="request_origin[stage_batches]" rel="nofollow" data-method="delete" href="/stage_items/8">Remove</a>
爲什麼不"request_origin"
使它進入#destroy
行動裏面的params
?