【发布时间】:2021-06-20 17:11:55
【问题描述】:
我尝试使用 Rails 6 通过 simple_form_for 更新客户对象
来自show.html.erb 我有<%= render partial: "form", object: @customer, as: 'customer' %>
我的表单示例:_form.html.erb
<%= simple_form_for customer, remote: true, url: customer_path(customer), method: :patch do |f| %>
不知道为什么,Rails 抛出 RoutingError
ActionController::RoutingError (No route matches [POST] "/customers/1"):
我的路线:
resources :customers, only: %i[show create new update]
【问题讨论】:
-
删除
url: customer_path(customer)和method: :patch -
不,还有 POST
-
您的
new和edit视图是什么样的? -
没有
new.html.rb或edit.html.erb。从动作show我的表单通过部分_form.html.erb呈现。我的请求参数有_method"=>"patch"但我最终得到 RoutingError [POST]
标签: ruby-on-rails patch put simple-form-for