From: Phrogz Date: 2010-01-13T04:30:07+09:00 Subject: Re: NOOB Question on Instance Variable On Jan 12, 12:17 pm, BlueHandTalking wrote: > In my ProjectsController I am creating 2 instance variables: Looks like you're talking about Ruby on Rails, not Ruby the language. > @displayphoto = Photo.find_by_project_id(params[:id]) And specifically here you appear to be using ActiveRecord. > The @displayphoto instance returns a nil object. That would appear to be because find_by_project_id is returning nil, given the code you've shown. > @photo = Photo.find_by_project_id(params[:id]) > works fine. So evidently it is the name @displayphoto > that is causing the problem. I believe that you are not testing what you think you are testing. Where are you later asking for the value of @photo versus @displayphoto. It is extremely unlikely that what you think is happening is true. > 1)  Must an instance variable always be the same >      name as the name of the class? No.