路线的定义如下:
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 %>
为什么表格不处理路线?
答案 0 :(得分:1)
您将其作为字符串而不是方法传递。删除引号即可。
<%= form_tag confirm_budgets_shopkeepers_path, remote: true do %>