Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Cookbook2 tutorial error: The error occured while evaluating nil.name

Reply
Thread Tools

Cookbook2 tutorial error: The error occured while evaluating nil.name

 
 
thundercleesed@gmail.com
Guest
Posts: n/a
 
      02-05-2006
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: </font>
23: </td>
24: <td><%= recipe.category.name %></td>
25: <td><%= recipe.date %></td>
26: </tr>
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

 
Reply With Quote
 
 
 
 
thundercleesed@gmail.com
Guest
Posts: n/a
 
      02-05-2006
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

 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      02-05-2006
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!

 
Reply With Quote
 
Curt Hibbs
Guest
Posts: n/a
 
      02-06-2006
Thanks, I'll see if we can get something added to the tutorial about this.

Curt

On 2/5/06, John <(E-Mail Removed)> wrote:
> 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!
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sys.WebForms.PageRequestManagerServerErrorExceptio n: An unknown error occured while p moiseszaragoza ASP .Net 0 12-12-2008 08:27 PM
An error occured while... =?Utf-8?B?SnVsaWE=?= ASP .Net 4 08-11-2007 08:23 AM
Error occured while running SChacko ASP .Net 0 07-13-2007 05:02 AM
Faulting application error occured while installing SQL Server service pack 3a(sp3a) on Windows Server 2003 Ent 64bit Edition Joshua Son Windows 64bit 0 03-16-2007 01:09 AM
Page won't load - "Error Occured While Processing Request" Brian Computer Support 4 09-08-2005 08:06 PM



Advertisments