Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMatthew Austin
16,452 PointsTrouble with 2nd code challenge for creating a route
The question is the following:
Set up a route to view an individual Pet. It should match GET requests with a path of /pets/ followed by the ID of the particular Pet: /pets/3, /pets/27, etc. You'll need to set it up so that the ID from the path is available within the controller as params[:id]. Matching requests should be routed to the show action method on PetsController
I feel like my code should be correct but i may be missing something.
I'm calling the http method get to the /pets/:id path where each pet can be called with the id parameter to: pets#show i.e. the pets controller with the show method.
Any help would be much appreciated!
Rails.application.routes.draw do
get '/pets/:id' to: 'pets#show'
end
1 Answer
William Li
Courses Plus Student 26,868 PointsOnly a small issue here.
Between 'pets/:id' and 'pets#show', you need to have a comma as a separator there.
Rails.application.routes.draw do
get '/pets/:id', to: 'pets#show'
end
hope it helps
Matthew Austin
16,452 PointsMatthew Austin
16,452 PointsWow good eye thank you.