No method?

Whenever i type what the book says which is…

xml.order_list(:for_product => @product.title) do
for o in @orders
xml.order do
xml.name(o.name)
xml.email(o.email)
end
end
end

it gives me this error that says…

NoMethodError in Info#who_bought

You have a nil object when you didn’t expect it!
The error occured while evaluating nil.title
Extracted source (around line #1):

im a newb so if you could help me out that would be great!

James Giannini wrote:

Whenever i type what the book says which is…

xml.order_list(:for_product => @product.title) do
for o in @orders
xml.order do
xml.name(o.name)
xml.email(o.email)
end
end
end

it gives me this error that says…

NoMethodError in Info#who_bought

You have a nil object when you didn’t expect it!
The error occured while evaluating nil.title
Extracted source (around line #1):

im a newb so if you could help me out that would be great!

This error isn’t exactly what it seems. It says the method “title”
doesn’t exist for “nil”, which makes sense. But where are you calling
“nil.title”? Look for where you are calling a method called “title”

@product.title

So, @product must be nil, meaning you havent assigned it to a value.
Check the code that assigns something to that variable and make sure
your putting the expected values in it.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs