У меня есть файл маршрутизации, подобный этому в Rails 5.2:
Rails.application.routes.draw do
resources :posts do
resource :comments
end
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
Почему нет маршрута /posts/:post_id/comments
для перечисления всех комментариев (comments#index
) к этому сообщению? и /posts/:post_id/comments/:id
маршрут для отображения одного конкретного комментария. Маршруты выглядят так:
>rake routes
Prefix Verb URI Pattern Controller#Action
new_post_comments GET /posts/:post_id/comments/new(.:format) comments#new
edit_post_comments GET /posts/:post_id/comments/edit(.:format) comments#edit
post_comments GET /posts/:post_id/comments(.:format) comments#show
PATCH /posts/:post_id/comments(.:format) comments#update
PUT /posts/:post_id/comments(.:format) comments#update
DELETE /posts/:post_id/comments(.:format) comments#destroy
POST /posts/:post_id/comments(.:format) comments#create
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
Это изменение по сравнению с Rails 4.2? Я впервые играю с 5.2, и большая часть моего опыта была до 3.2.