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

Discussion in 'Ruby' started by thundercleesed@gmail.com, Feb 5, 2006.

  1. Guest

    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
    , Feb 5, 2006
    #1
    1. Advertising

  2. Guest

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

    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
    , Feb 5, 2006
    #2
    1. Advertising

  3. John Guest

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

    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!
    John, Feb 5, 2006
    #3
  4. Curt Hibbs Guest

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

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

    Curt

    On 2/5/06, John <> 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!
    >
    >
    >
    Curt Hibbs, Feb 6, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVsaWE=?=

    An error occured while...

    =?Utf-8?B?SnVsaWE=?=, Dec 1, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,214
    Lizard Man
    Aug 11, 2007
  2. SChacko

    Error occured while running

    SChacko, Jul 13, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    470
    SChacko
    Jul 13, 2007
  3. moiseszaragoza
    Replies:
    0
    Views:
    848
    moiseszaragoza
    Dec 12, 2008
  4. supraja
    Replies:
    2
    Views:
    519
  5. Christoffer Sawicki
    Replies:
    5
    Views:
    241
    Christoffer Sawicki
    Sep 2, 2006
Loading...

Share This Page