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.
yanchung cheng11,640 Points
Finding A Model Object
Not sure what is up with this.
Instruction - We've set up the following in routes.rb: get '/pets/:id', to: 'pets#show' But that controller action method doesn't exist yet. Create it now. Within the method, use the :id parameter to find the matching Pet record, and assign the result to the @pet instance variable.
Error - Bummer! NameError: undefined local variable or method `pets' for PetsController:Class Did you mean? puts Restart Get Help Recheck work
My Answer - class PetsController < ApplicationController
@pet = Pet.find(pets[:id]) end
def show @pet = Pet.find(params[:id]) end
You're not defining a show method, I just had the same problem!
def show *code* end