【发布时间】:2021-07-21 16:30:44
【问题描述】:
我目前正在将正确的路由添加到旧版 Rails 应用程序中,我似乎无法使用 PATCH、PUT 和 DELETE 路由,因为应用程序目前的工作方式仅基于 GET 和 POST 路由。
所以我已经实现了 REST 路由,但目前,我需要重定向 PATCH、PUT 和 DELETE,直到我们可以更改它以使用正确的路由。
这是我在更新时得到的:
这些是自定义字段的路由# custom_fields
resources :custom_fields, except: %i[show destroy] do
get :disable, on: :member
collection do
get :list
get :edit
get :disable
get :enable
get :order_fields
post :process_order_fields
end
end
# remap wrong implmentation of paths
get '/custom_fields/edit/:id', to: redirect('/custom_fields/%{id}/edit')
我尝试了以下方法
post '/custom_fields/:id', to: redirect(custom_field_path(id: %{id}))
但没有骰子。
【问题讨论】:
标签: ruby-on-rails ruby routes ruby-on-rails-5