Reputation: 179
I'm new to Rails, and I'm setting up models/controllers for Course
and some other models.
When I visit the /courses/show
URL in my browser I get the following error:
Couldn't find Course with 'id'=
Here's the relevant line from my rake routes
and routes.rb
:
courses_show GET /courses/show(.:format) courses#show
get 'courses/show'
Upvotes: 1
Views: 115
Reputation: 27961
You have specified the four routes without any :id
parameter, I don't know why you would expect them to have an :id
parameter.
I'd recommend that you read the Rails guide on routing and also read the comments in the generated config/routes.rb
, in that file you'll see comments like this:
# Example of regular route:
# get 'products/:id' => 'catalog#view'
So, extrapolating that to your example you might end up with:
get 'courses/:id' => 'courses#show'
The example that follows that one shows how to add a named route helper using the :as
option:
get 'courses/:id' => 'courses#show', as: :courses_show
Something you'll also see when you read the guide or the comments is that you can use the resources
helper to create standard restful routes.
Upvotes: 1