根据报错信息,可以看到在routes.rb文件中,只为products资源定义了index, new, create, edit, update这些动作。然而,在_form.html.erb文件中,你使用了form_with帮助器方法,并将url参数设置为admin_products_path,但是你没有在routes.rb中为products资源定义destroy动作。

为了解决该问题,你可以在routes.rb文件中添加destroy动作,如下所示:

namespace :admin do
  resources :products, only: [:index, :new, :create, :edit, :update, :destroy]
end

然后,重新启动服务器并刷新页面,这样就能正确地匹配到[DELETE] "/admin/products/:id"路由了。

rails项目中routesrb namespace admin do resources products only index new create edit update end_formhtmlerb= form_with model product url admin_products_path local true do f 报错 No route matches PATC

原文地址: https://www.cveoy.top/t/topic/icqh 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录