[英]Rails Routes missing prefix for resources post route
我创建了一个新的 controller 和一个新的 model 的操作。 我已经设置了如下的rails路线:
namespace :api do
namespace :v1 do
resources :universes
end
end
我正在尝试使用路径助手(例如get(api_v1_universe_path(universe.id))
)编写一些 RSpec 测试。 当我 go 查看邀请的帖子路由时,路由缺少前缀,如下所示:
POST /api/v1/universes(.:format) api/v1/universes#create
new_api_v1_universe GET /api/v1/universes/new(.:format) api/v1/universes#new
edit_api_v1_universe GET /api/v1/universes/:id/edit(.:format) api/v1/universes#edit
api_v1_universe GET /api/v1/universes/:id(.:format) api/v1/universes#show
我知道我可以手动添加一行像post "/", to: "universe#create", as: "create"
来获取带有前缀的路由。 但是,我想知道是什么导致 post 路由中缺少前缀,所以我可以修复它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.