Shreekar Joshi
2006-Apr-24 06:19 UTC
[Rails] Called id for nil, which would mistakenly be 4 -- if you really wanted the idof nil, use object_id - solved
Hi Bill, No I am not using Instant Rails.>There are lots of variations possible. Typos and capitalisationrepresent 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, notrecipe.id -- Tom Mornini Tom: Thanks... I see my error now. Regards Shreekar Joshi Hi Shreekar, Shreekar Joshi wrote: <snip>> 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). > Any ideas?Two suggestions.... 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 http://instantrails.rubyforge.org/wiki/wiki.pl 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. Best regards, Bill
Maybe Matching Threads
- Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
- Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
- FCGI: warning: Object#id will be deprecated; use Object#object_id?
- Challenge for object_id, Garbage Value
- warning: Object#id will be deprecated; use Object#object_id