FROM: http://edgeguides.rubyonrails.org/routing.html
TAKEAWAY: you want routes that are DESCRIPTIVE, but you also want routes that are not stupid deep. therefore, make shallow routes. there is an shallow
option for this.
- only build routes with the minimal amount of information to uniquely identify the resource, like this:
resources :posts do
resources :comments, only: [:index, :new, :create]
end
resources :comments, only: [:show, :edit, :update, :destroy]
- RAILS AUTOMAGIC
A. use the shallow option on any resource to make it shallow
resources :posts do
resources :comments, shallow: true
end
B. or do it on the parent resource to make everything shallow
resources :posts, shallow: true do
resources :comments
resources :quotes
resources :drafts
end
C. you could also do this like this. this is the same as B.
shallow do
resources :posts do
resources :comments
resources :quotes
resources :drafts
end
end