# Cookbook2 tutorial error: The error occured while evaluatin

**URL:** <https://www.ruby-forum.com/t/cookbook2-tutorial-error-the-error-occured-while-evaluatin/101300>\
**Category:** Ruby\
**Created:** [February 5, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/cookbook2-tutorial-error-the-error-occured-while-evaluatin/101300 "2006-02-05T18:09:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 5, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/cookbook2-tutorial-error-the-error-occured-while-evaluatin/101300/1 "2006-02-05T18:09:08Z")

</div>

I am following the Cookbook2 tutorial on the InstantRails website (  
[http://instantrails.rubyforge.org/tutorial/index.html](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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 5, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/cookbook2-tutorial-error-the-error-occured-while-evaluatin/101300/2 "2006-02-05T18:15:10Z")

</div>

I forgot to mention I am getting the error when I attempt to “add a  
new recipe like the one shown in Figure 56.”.

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 5, 2006, 9:10pm UTC](https://www.ruby-forum.com/t/cookbook2-tutorial-error-the-error-occured-while-evaluatin/101300/3 "2006-02-05T21:10:25Z")

</div>

Well I figured it out in case anyone searches for this same problem…  
The receipe table had a row with a category\_id of 0. Note that the  
category table does not have a row for 0.

Not sure how this wound up in the DB like that, but I manually fixed it  
by changing the 0 to a 1.

Hope this helps someone else learning ruby!

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 6, 2006, 5:43am UTC](https://www.ruby-forum.com/t/cookbook2-tutorial-error-the-error-occured-while-evaluatin/101300/4 "2006-02-06T05:43:39Z")

</div>

Thanks, I’ll see if we can get something added to the tutorial about  
this.

Curt
