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 trial

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'