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.

Ruby Rails Routes and Resources A Route to a Read Action Set Up a URL Parameter

Your route's path needs to include an "id" URL parameter.

Your route's path needs to include an "id" URL parameter.

routes.rb
Rails.application.routes.draw do
  # YOUR CODE HERE
    get '/pets/', to: 'pets/3'
    get '/pets/:id', to: 'pages/27'

end

1 Answer

Dillon Wyatt
Dillon Wyatt
5,990 Points
Rails.application.routes.draw do
  # YOUR CODE HERE
    get '/pets/', to: 'pets/3'
    get '/pets/:id', to: 'pages/27'
end

https://guides.rubyonrails.org/routing.html

I think the resource above might help you.

A Rails Route includes a few basic parts and I think you are confusing one of them.

A METHOD (GET, POST, etc) A PATH ('/url-address/') A CONTROLLER + ACTION (to: 'pets#show') An ALIAS (as: 'pet')

An ID param would aid you in getting to the individual pet show. I am not exactly sure what the test wants but maybe

get '/pet/:id', to: 'pets#show', as: 'pet'