Ruby on rails 如何创建此路线?

Ruby on rails 如何创建此路线?,ruby-on-rails,ruby,ruby-on-rails-4,routes,Ruby On Rails,Ruby,Ruby On Rails 4,Routes,我有以下路线: resources :articles, except: [:index] do collection do get 'author/:id/articles' => 'articles#index', as: 'index_articles' end end 这导致: GET /api/v1/articles/:id/author/:id/articles(.:format) 我如何将此转换为以下内容: GET /api/v1/au

我有以下路线:

resources :articles, except: [:index] do
   collection do
      get 'author/:id/articles' => 'articles#index', as: 'index_articles'
   end
end
这导致:

GET    /api/v1/articles/:id/author/:id/articles(.:format)
我如何将此转换为以下内容:

GET    /api/v1/author/:id/articles(.:format)  
写这个

get 'author/:id/articles' => 'articles#index', as: 'index_articles'

resources:articles
块之外。

如果你写这个
get'author/:id/articles'=>'articles#index',如:'index#u articles'
resources:articles
之外,你将得到想要的路线。是的,非常感谢,你能把这个作为答案添加吗?谢谢,使用
成员
替代其他解决方案是否有优势。或者这只是惯例?只是惯例,也是。如果您希望在以后添加额外的路由,那么围绕资源范围比使用单独的路由要好得多
get 'author/:id/articles' => 'articles#index', as: 'index_articles'