Undefined local variable in partial

i can’t get rid of the following error:

ActionView::TemplateError (undefined local variable or method
`order_line’
for #<#Class:0xb75b2090:0xb75b1f28>) on line #13 of
app/views/admin/_order_line.rhtml:
10:
11:


12:
13:
<%= h(order_line.name) %>

14:
<%= h(order_line.address) %>

15:

The partial is called from within a view (ship.rhtml):

<%= render(:partial => “order_line”, :collection => @pending_orders)
%>

The PragProg-Rails book explains the following:

‘‘The order_line parameter also tells Rails to set a local variable
called
order_line to the value of the order currently being rendered. This
variable
is available only inside the partial template.’’

So why do i get the error above??

By the way: is it right that i get a blank page or should i see an
error-page from rails?
scrolling down my development.log is see the following:

ActionView::ActionViewError (No rhtml, rxml, or delegate template found
for
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2
/lib/action_controller/templates/rescues/template_error.rhtml):
/usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_view/base.rb:281:in
`pick_template_extension’

Any hints?

Regards,
Torsten

having trouble with that page as well but I am getting this error

You have a nil object when you didn’t expect it!
The error occured while evaluating nil.name

Not sure why your getting that error that is strange.

Brian

Spectre013 wrote:

having trouble with that page as well but I am getting this error

You have a nil object when you didn’t expect it!
The error occured while evaluating nil.name

Not sure why your getting that error that is strange.

Brian

Does anyone know what the fix for this is? I’m following along with the
first addition of agile web development with rails and it’s been going
great until I got to page 118 and ran into the exact problem described
above.

_order_line.rhtml:

<%= h(order_line.name) %>
<%= h(order_line.address) %>

ship.rhtml
<%= render(:partial => “order_line”, :collection => @pending_orders)
%>

The error is:
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.name

Any help would much appreciated.

-Theron

I figured out the problem…it turns out that I had named a variable in
my order model pending_order and named it pending_orders in my
admin_controller so it wasn’t sending anything to my partial. That was a
fun two hours that I’ll never get back. :slight_smile:

Game on.