Missing: route identifiers when creating resources

My rake routes

after creating the resource: articles say I should get:

Prefix Verb      URI Pattern                  Controller#Action
articles  GET    /articles(.:format)          articles#index
          POST   /articles(.:format)          articles#create
new_article  GET /articles/new(.:format)      articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article  GET     /articles/:id(.:format)      articles#show
         PATCH   /articles/:id(.:format)      articles#update
         PUT     /articles/:id(.:format)      articles#update
         DELETE  /articles/:id(.:format)      articles#destroy
    root GET     /                            welcome#index

      

However, my routes are always missing those with: id in them.

Prefix Verb   URI Pattern              Controller#Action
articles POST     /articles(.:format)      articles#create
new_articles  GET /articles/new(.:format)  articles#new
edit_articles GET /articles/edit(.:format) articles#edit
          GET     /articles(.:format)      articles#show
          PATCH   /articles(.:format)      articles#update
          PUT     /articles(.:format)      articles#update
          DELETE  /articles(.:format)      articles#destroy
     root GET     /                        welcome#index

      

+3


source to share


1 answer


I think you added to routes:

resource :articles

      

instead:



resources :article

      

A singular resource is used when you don't need to provide id

to define a resource. Those. when you are working with the current user profile:/profile

+6


source







All Articles