我有以下途徑:如何創建此路線?
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'作者/:id/articles'=>'articles#index',作爲''index_articles''在'resources:articles'之外,你將獲得期望的路線。 –
是的,非常感謝你,你會添加這個答案嗎? – Nick