Generic-user-small Mark McCollum 2 posts

Hi,
I am working my way through the book, and have just completed iteration A4. I can load the index page with no problem, but when I click the link to create a new product I get the following error:

NoMethodError in Products#new

Showing layouts/products.html.erb where line #16 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 #16):

13:

Listing products


14:
15: <table cellspacing="0" cellpadding="5">
16: <% for product in @products %>

I also get similar errors when using the other links on the page. Any idea what is causing this?

 
Samr_small_small Sam Ruby 197 posts

The lines you quoted look like they are from app/views/products/index.html.erb and not from app/views/layouts/products.html.erb

By any chance, did some of these lines get added (appended?) to the end of the layout? Check both files against the links provided above.

 
Generic-user-small Mark McCollum 2 posts

You hit it right on the nose. I must have pasted into the wrong file. Thanks!

3 posts, 2 voices