YvesHendseth
YvesHendseth

Reputation: 1181

rails generates wrong 'show' route

i have following show function:

def show
    @article = Article.find(params[:id])
end

my routes.rb looks like this:

resource :articles

but when i run rake routes, i get this output:

     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    /  

as you can see the articles#show route is wrong because an :id is needed to show a single article.

Upvotes: 0

Views: 33

Answers (1)

Ursus
Ursus

Reputation: 30056

resource :articles

should be

resources :articles

But you have discovered what resource method does :)

Upvotes: 1

Related Questions