Reputation: 620
if I have
resources :projects
root to: "projects#index"
in my routes file would it be more succinct to do
resource :projects
root to: "projects#index"
or any reason this won't work because I don't see anyone doing it
Upvotes: 0
Views: 301
Reputation: 96934
No, because they’re two different methods that do two different things. resources
is meant for when you have more than one of the model object (a plural resource), whereas resource
is meant for when it is a singular resource. For this reason, using resource
does not create an index
route and none of the routes take an ID parameter in the URL. To quote the docs:
Sometimes, you have a resource that clients always look up without referencing an ID. A common example, /profile always shows the profile of the currently logged in user. In this case, you can use a singular resource to map /profile (rather than /profile/:id) to the show action:
resource :geocoder
That said, I wouldn't really consider saving one character “more succinct” anyway.
Upvotes: 3