small medium large xlarge

Generic-user-small
16 May 2008, 23:37
Casey Smith (5 posts)

I get an error when I run http://localhost:3000/login/login I get this error message=

NoMethodError in Login#index

Showing login/index.html.erb where line #3 raised:

You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each

Extracted source (around line #3):

1: <h1>Your Pragmatic Catalog</h1> 2: 3: <% for product in @products -%> 4: <div class="entry"> 5: <%= image_tag(product.image_url) %> 6: <h3><%= h(product.title) %></h3>

Samr_small_pragsmall
17 May 2008, 02:04
Sam Ruby (634 posts)

Um, you are ahead of me. Check the preface to the third edition for what chapters are ready. Either that, or look for the visual clues in the form of the colors of the top and bottom borders on each page.

Generic-user-small
17 May 2008, 04:21
Casey Smith (5 posts)

Thanks Sam I will check that. Is there a place just to get problems answers that I come across?

Samr_small_pragsmall
17 May 2008, 21:14
Sam Ruby (634 posts)

I’ll try to explore further tomorrow, but to get past that specific problem, modify app/controllers/login_controller.rb thus:

def index
  @products = Product.find(:all)
  @total_orders = Order.count
end
Samr_small_pragsmall
20 May 2008, 02:24
Sam Ruby (634 posts)

This will be corrected in the next beta, but click on the following for the correct version of “app/views/login/index.rhtml”:http://media.pragprog.com/titles/rails2/code/depot_r/app/views/login/index.rhtml

Sorry for the inconvenience.

You must be logged in to comment