路线的定义如下:
post '/shopkeepers/confirm_budgets', to: 'shopkeepers#confirm_budgets', as: 'shopkeepers_confirm_budgets'
我并不热衷于语法方法,但是作为一个遗留应用程序……它在耙路径中显示为:
shopkeepers_confirm_budgets POST /shopkeepers/confirm_budgets(.:format) shopkeepers#confirm_budgets
表格正在呼叫:
<%= form_tag('shopkeepers_confirm_budgets_path', remote: true) do %>
以下也失败
<%= form_tag('confirm_budgets_shopkeepers_path', remote: true) do %>
应用程序无法识别它:
Started POST "/shopkeepers/shopkeepers_confirm_budgets_path" for ::1 at 2020-09-13 10:22:22 +0200
ActionController::RoutingError (No route matches [POST] "/shopkeepers/shopkeepers_confirm_budgets_path"):
但是,如果我使用button_to翻转问题,该过程将运行。
<%= button_to shopkeepers_confirm_budgets_path, remote: true, params: {criteria: "#{shop.id}", value: number_with_precision(available_funds.to_d/100, precision: 2)} do %>
<% end %>
为什么表格不处理路线?
您将其作为字符串而不是方法传递。删除引号即可。
<%= form_tag confirm_budgets_shopkeepers_path, remote: true do %>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句