Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Routes :shallow => true

Wondering why my /articles route is not coming up when I apply :shallow => true?

routes.rb

resources :users, :shallow => true do
  resources :articles
end

Also tried this:

resources :users do
  resources :articles, :shallow => true
end

Visiting /articles won't show me all articles from any user as expected, but I can still visit /articles/:id just fine. Is this expected behavior?

like image 923
botbot Avatar asked Dec 05 '22 15:12

botbot


1 Answers

The shallow: true option does not provide an index resource according to the docs. Therefore, you will not be able to access just /articles. So yes, this is the expected behavior.

like image 85
Peter Brown Avatar answered Dec 17 '22 08:12

Peter Brown