开始新的rails 5 api项目,创建模型,添加了rails_admin
。我可以在/ admin上看到一个漂亮的管理面板,我可以做除edit
和delete
之外的所有事情。
{"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'"}...]}}`
我检查了我的路线,并且在EDIT或DELETE
上没有提供实际的POSTRoutes 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
答案 0 :(得分:1)
看到一篇类似的SO帖子here。我认为这是因为rails-5-api
删除了api
s
解决方案是在application.rb
config.middleware.use Rack::MethodOverride