I am following the Cookbook2 tutorial on the InstantRails website (
http://instantrails.rubyforge.org/tutorial/index.html ). I am almost
finshed with the tutorial but have started getting the following error:
NoMethodError in Recipe#list
Showing app/views/recipe/list.rhtml where line #24 raised:
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.name
Extracted source (around line #24):
21: :confirm => “Really delete #{recipe.title}?” %>
22:
23:
24: <%= recipe.category.name %>
25: <%= recipe.date %>
26:
27: <% end %>
RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/app/views/recipe/list.rhtml:24
#{RAILS_ROOT}/app/views/recipe/list.rhtml:11
And here are the first three lines of the Full Trace:
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:268:in
compile_and_render_template' C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:244:in
render_template’
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:205:in
`render_file’
I have attempted double checking the code throughout the tutorial, but
I am just not seeing what is causing the error. I figure it is a small
typing error, but I do not know how to isolate which section of code it
is in. Any suggestions would be welcomed.
Thank you for your time.
John