rails_admin 无法编辑和删除:没有路由匹配 [POST] /admin/model/id/edit 和 /admin/model/id/delete

rails_admin Could not edit and delete: No route matches [POST] /admin/model/id/edit and /admin/model/id/delete

开始了一个新的 rails 5 api 项目,创建了模型,添加了 rails_admin。我可以在 /admin 上看到一个漂亮的管理面板 运行,除了 editdelete.

我可以做任何事情
{"status":404,"error":"Not Found","exception":"#\u003cActionController::RoutingError: No route matches [POST] \"/admin/city/3/edit\"\u003e","traces":{"Application Trace":[],"Framework Trace":[{"id":0,"trace":"actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'"}...]}}
{"status":404,"error":"Not Found","exception":"#\u003cActionController::RoutingError: No route matches [POST] \"/admin/city/3/delete\"\u003e","traces":{"Application Trace":[],"Framework Trace":[{"id":0,"trace":"actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'"}...]}}`

我检查了我的路线,事实上 POST 不存在于编辑或删除

Routes for RailsAdmin::Engine:
  dashboard GET         /                                      rails_admin/main#dashboard
      index GET|POST    /:model_name(.:format)                 rails_admin/main#index
        new GET|POST    /:model_name/new(.:format)             rails_admin/main#new
     export GET|POST    /:model_name/export(.:format)          rails_admin/main#export
bulk_delete POST|DELETE /:model_name/bulk_delete(.:format)     rails_admin/main#bulk_delete
bulk_action POST        /:model_name/bulk_action(.:format)     rails_admin/main#bulk_action
       show GET         /:model_name/:id(.:format)             rails_admin/main#show
       edit GET|PUT     /:model_name/:id/edit(.:format)        rails_admin/main#edit
     delete GET|DELETE  /:model_name/:id/delete(.:format)      rails_admin/main#delete
show_in_app GET         /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app

看到一个类似的 SO Post here。我认为发生这种情况是因为 rails-5-api 删除了许多 apis

不需要的中间件

解决方案是在 application.rb

中添加这个
config.middleware.use Rack::MethodOverride