SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jun 2008
    Location
    Orange County
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Simply Rails 2 - ch. 9 : rake test gives 6 errors while evaluating nil.login

    Hi,

    I'm working thru the tutorial app 'shovell' as found in Simply Rails 2. I'm getting some error on testing at the end of chapter 9. the app runs fine in browser but give...

    32 tests, 66 assertions, 0 failures, 6 errors
    -instead of : 32 tests, 72 assertions, 0 failures, 0 errors

    Below is the errror, its the same on all 6:

    ActionView::TemplateError: You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.login
    On line #4 of stories/_story.html.erb

    1: <% div_for(story) do %>
    2: <h3><%= link_to story.name, story %></h3>
    3: <p>
    4: Submitted by: <%= story.user.login %> |
    5: Score: <%= story.votes_count %>
    6: </p>
    7: <% end %>
    app/views/stories/_story.html.erb

    If anyone can point me in the right direction I'd be stoked. thanks in advance for sharing!

  2. #2
    l 0 l silver trophybronze trophy lo0ol's Avatar
    Join Date
    Aug 2002
    Location
    Palo Alto
    Posts
    5,329
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    As you've probably surmised, the problem's with the <&#37;= story.user.login %> portion. It looks like the story that you're looking at isn't correctly associated with an associated User object. That's why you're getting errors: you're trying to call the method "login" on something that doesn't exist (the User object). I'm not sure the setup you have going on, but perhaps take a look at the fixtures or otherwise make sure that whichever Story you're creating is correctly hooked up with a User.

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Location
    Orange County
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Zach,

    Thanks for the tip, my issue was resolved my correcting the user data in the fixtures. Best regards,

    Bill


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •