【发布时间】:2016-01-29 09:00:13
【问题描述】:
我有以下路线:
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)
【问题讨论】:
-
如果你在
resources :articles之外写这个get 'author/:id/articles' => 'articles#index', as: 'index_articles'你会得到想要的路线。 -
是的,非常感谢,您会添加这个作为答案吗?
标签: ruby-on-rails ruby ruby-on-rails-4 routes