laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Feb-15 00:44 UTC
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
=====================<div class="ec_line_item"
style="width:100%">
<!-- stuff -->
<div
class="summaryField"><%summary_line_item.prescription_number
%></div>
<div class="summaryField"><%=
summary_line_item.description
%></div>
<!-- more stuff -->
</div>
======================End _summary_line_item.rhtml
======================
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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Rick DeNatale
2008-Feb-15 12:41 UTC
Re: What is the right way to name my local variable in my partial?
On Thu, Feb 14, 2008 at 7:44 PM, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org <laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote:> 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". - DaveHaving the other partial shouldn''t restrict you, we''re talking about local variables here. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Feb-15 16:13 UTC
Re: What is the right way to name my local variable in my partial?
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>
<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</
td>
</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
On Feb 15, 6:41 am, "Rick DeNatale"
<rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On Thu, Feb 14, 2008 at 7:44 PM,
laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
>
> <laredotorn...-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org> wrote:
> > 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.
>
> --
> Rick DeNatale
>
> My blog on Rubyhttp://talklikeaduck.denhaven2.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Rick DeNatale
2008-Feb-15 17:05 UTC
Re: What is the right way to name my local variable in my partial?
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 %> -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Feb-15 17:54 UTC
Re: What is the right way to name my local variable in my partial?
As a commercial that I''ve seen would say ... brilliant! Thanks, - On Feb 15, 11:05 am, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 %> > > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.com/--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---