1
This маршрутов настройкиМелкие маршрутов внутри пространство имен с: путем не Param работать
namespace :api, path: nil, except: [:new, :edit] do
resources :blogs do
resources :comments
end
end
дал мне это, и это нормально.
GET /blogs/:blog_id/comments(.:format) api/comments#index
POST /blogs/:blog_id/comments(.:format) api/comments#create
GET /blogs/:blog_id/comments/:id(.:format) api/comments#show
PATCH /blogs/:blog_id/comments/:id(.:format) api/comments#update
DELETE /blogs/:blog_id/comments/:id(.:format) api/comments#destroy
GET /blogs(.:format) api/blogs#index
POST /blogs(.:format) api/blogs#create
GET /blogs/:id(.:format) api/blogs#show
PATCH /blogs/:id(.:format) api/blogs#update
DELETE /blogs/:id(.:format) api/blogs#destroy
Но когда я добавить "неглубоко: правда" с настройкой выше
namespace :api, path: nil, except: [:new, :edit] do
resources :blogs, shallow: true do
resources :comments
end
end
нежелательный путь '/ апи' идет вверх.
/api/blogs/:blog_id/comments(.:format) api/comments#index
/api/blogs/:blog_id/comments(.:format) api/comments#create
/api/comments/:id(.:format) api/comments#show
/api/comments/:id(.:format) api/comments#update
/api/comments/:id(.:format) api/comments#destroy
/blogs(.:format) api/blogs#index
/blogs(.:format) api/blogs#create
/api/blogs/:id(.:format) api/blogs#show
/api/blogs/:id(.:format) api/blogs#update
/api/blogs/:id(.:format) api/blogs#destroy
Ожидается ли такое поведение в Rails 4? Должен ли я писать каждый ресурс соответственно?
Спасибо! Буквально не знал этого! –
Большое вам спасибо, это именно то, что я хочу! – chikaram