Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Trouble 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
William LiCourses Plus Student 26,867 Points
Only 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