B
BlueHandTalking
I have a class photo. It belongs_to a project.
In my ProjectsController I am creating 2 instance variables:
@displayphoto = Photo.find_by_project_id(params[:id])
....and also
@photo = @project.build_photo
The @displayphoto instance returns a nil object.
However,
@photo = Photo.find_by_project_id(params[:id])
works fine. So evidently it is the name @displayphoto
that is causing the problem.
So I have 2 questions:
1) Must an instance variable always be the same
name as the name of the class?
2) If the above is true, how can I create 2 separate
instance variables in my controller for the same class?
Thanks,
Jet
In my ProjectsController I am creating 2 instance variables:
@displayphoto = Photo.find_by_project_id(params[:id])
....and also
@photo = @project.build_photo
The @displayphoto instance returns a nil object.
However,
@photo = Photo.find_by_project_id(params[:id])
works fine. So evidently it is the name @displayphoto
that is causing the problem.
So I have 2 questions:
1) Must an instance variable always be the same
name as the name of the class?
2) If the above is true, how can I create 2 separate
instance variables in my controller for the same class?
Thanks,
Jet