简体   繁体   English

Ruby on Rails重命名嵌套资源

[英]ruby on rails rename nested resources

I have following routes 我有以下路线

resources :posts, path: :blog do
    resources :comments, path: :comments do
    end
  end


  devise_scope :user do
    resources :posts, path: :blog do
      resources :comments do

      end
    end
  end

this gives me 这给了我

post_comments GET    /news/:post_id/comments(.:format)          comments#index
                  POST   /news/:post_id/comments(.:format)          comments#create
 new_post_comment GET    /news/:post_id/comments/new(.:format)      comments#new
edit_post_comment GET    /news/:post_id/comments/:id/edit(.:format) comments#edit
     post_comment GET    /news/:post_id/comments/:id(.:format)      comments#show
                  PATCH  /news/:post_id/comments/:id(.:format)      comments#update
                  PUT    /news/:post_id/comments/:id(.:format)      comments#update
                  DELETE /news/:post_id/comments/:id(.:format)      comments#destroy
            posts GET    /news(.:format)                            posts#index
                  POST   /news(.:format)                            posts#create
         new_post GET    /news/new(.:format)                        posts#new
        edit_post GET    /news/:id/edit(.:format)                   posts#edit
             post GET    /news/:id(.:format)                        posts#show
                  PATCH  /news/:id(.:format)                        posts#update
                  PUT    /news/:id(.:format)                        posts#update
                  DELETE /news/:id(.:format)                        posts#destroy
                  GET    /news/:post_id/comments(.:format)          comments#index
                  POST   /news/:post_id/comments(.:format)          comments#create
                  GET    /news/:post_id/comments/new(.:format)      comments#new
                  GET    /news/:post_id/comments/:id/edit(.:format) comments#edit
                  GET    /news/:post_id/comments/:id(.:format)      comments#show
                  PATCH  /news/:post_id/comments/:id(.:format)      comments#update
                  PUT    /news/:post_id/comments/:id(.:format)      comments#update
                  DELETE /news/:post_id/comments/:id(.:format)      comments#destroy
                  GET    /news(.:format)                            posts#index
                  POST   /news(.:format)                            posts#create
                  GET    /news/new(.:format)                        posts#new
                  GET    /news/:id/edit(.:format)                   posts#edit
                  GET    /news/:id(.:format)                        posts#show
                  PATCH  /news/:id(.:format)                        posts#update
                  PUT    /news/:id(.:format)                        posts#update
                  DELETE /news/:id(.:format)                        posts#destroy
             root GET    /                                          posts#index
  1. why are there routes multiple routes that are exactly the same? 为什么会有多条完全相同的路由?
  2. how do i rename for example the news/edit to news update inside a nested resource? 我如何在嵌套资源内将新闻/编辑重命名为新闻更新?

Thank you ! 谢谢 !

您多次调用帖子,路径,博客和评论的资源,只是在更改顺序,但链接是相同的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM