No I am not using Instant Rails.
There are lots of variations possible. Typos and capitalisation
represent the largest proportion of errors I personally have made.
Thanks a lot....solved the problem. Changed recipes (plural) in
controller file to recipe (singular). That teaches me to pay real
attention to casing. (forgive me, I am from the VS and VB world
Actually, the error is telling you that recipe itself is nil, not
– Tom M.
Tom: Thanks… I see my error now.
Shreekar Joshi wrote:
I have encountered following error:
Called id for nil, which would mistakenly be 4 – if you really wanted
the id of nil, use object_id
I have come to this page from edit link from the show page. This show
page is generated by the scaffolding. The url for this link seems to
be correct -
recipe/edit/2 (where 2 is id of the recipe).
First, if you’re using InstantRails, a working version of the cookbook
application is included and you can use that to check against the code
you’re having problems with. If you’re not using InstantRails, you
might want to download it from
Second, to address your problem specifically, the error you’re getting
results from trying to access an object in a view that was not
initialized in the controller. Views typically use instance variables.
So the problem usually traces back to something like…
recipe = Recipe.find(:all) # in this case, recipe is a local variable
that the view sill not have access to
@Recipe = Recipe.find(:all) # in this case, @Recipe is an instance
variable, but it’s a different instance variable than @recipe.
There are lots of variations possible. Typos and capitaliation
represent the largest proportion of errors I personally have made. If
this doesn’t solve your problem, please post the controller code and I’m
sure someone will be able to help.