user1328114
user1328114

Reputation: 71

Missing routes in rails after using resource keyword

Not sure what the issue is here, but I have a basic line in my routes.rb:

resource :videos

But I don't see all the paths. Namely:

GET /videos/:id

I only see the following when running "rake routes":

videos      POST   /videos(.:format)              videos#create
new_videos  GET    /videos/new(.:format)          videos#new
edit_videos GET    /videos/edit(.:format)         videos#edit
            GET    /videos(.:format)              videos#show
            PUT    /videos(.:format)              videos#update
            DELETE /videos(.:format)              videos#destroy

What am I missing? Thanks!

Upvotes: 1

Views: 1250

Answers (2)

klaffenboeck
klaffenboeck

Reputation: 6377

Change your line to resources :videos, and the missing route will magically appear

Upvotes: 4

jtsagata
jtsagata

Reputation: 2383

You make videos a singular resource, but videos is a collection so you have to do :

resources :videos

http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions

Upvotes: 4

Related Questions