What is the right way to name my local variable in my partial?

Hi,

I have this invocation of a partial:

<%= render :partial => 'summary_line_item', @collection =>
@ec_order.ec_line_items %>

I thought just by naming the partial "summary_line_item", each item
from the collection would be named "summary_line_item". But I get
this error:

NoMethodError in Order#summary
Showing order/_summary_line_item.rhtml where line #12 raised:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.prescription_number

Here's the code for the partial

=====================Begin _summary_line_item.rhtml

  NoMethodError in Order#summary
Showing order/_summary_line_item.rhtml where line #12 raised:
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.prescription_number

Here's the code for the partial

=====================Begin _summary_line_item.rhtml

<div class="ec_line_item" style="width:100%">
           <!-- stuff -->

Perhaps it's something in the above <!-- stuff -->

           <div class="summaryField"><%=
summary_line_item.prescription_number %></div>

...

Any idea how to properly name that loop variable in the partial? I
can name it anything other than "ec_line_item", b/c I already have
another partial named "_ec_line_item.rhtml". - Dave

Having the other partial shouldn't restrict you, we're talking about
local variables here.

I guess I should take a step back. Given this from my summary.rhtml
file, how could I take the loop and convert it into a partial?

<% for summary_line_item in @ec_order.ec_line_items %>
<div class="ec_line_item" style="width:100%">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
     <tr><td class="lineItemHeader" style="background-image:url('<%=
image_path('/images/INSIDE_MENU_BAR-GreyRepeat_SM.gif');
%>');">Prescription #<span class="prescriptionNumber">#</span></td></

     <tr><td style="background-color:#FFFFCC;">
       <table cellpadding="3" cellspacing="0" border="0" width="100%">
         <tr>
           <td rowspan="2" valign="middle" align="center"><%=
image_tag '/images/RxICON_Cream.gif', options = {:alt => ""} %></td>
           <td align="center" class="summaryFieldHeader">Refill
Number</td>
           <td align="center" class="summaryFieldHeader">Description</

         </tr>
         <tr>
           <td align="center" class="summaryField"><%=
summary_line_item.prescription_number %></td>
           <td align="center" class="summaryField"><%=
summary_line_item.description %></td>
         </tr>
       </table>
     </td></tr>
</table>
</div>
<% end %>

Thanks, - Dave

Ahh, I think I see your problem now:

<%= render :partial => 'summary_line_item', @collection =>
@ec_order.ec_line_items %>

should be:

<%= render :partial => 'summary_line_item', :collection =>
@ec_order.ec_line_items %>

As a commercial that I've seen would say ... brilliant! Thanks, -