laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org
2008-Feb-14 02:04 UTC
Is there an implicit index in this loop?
Hi, I have the partial below ... <% fields_for "ec_order[ec_line_item_attributes][]", ec_line_item do |ec_line_item_form| %> <div class="ec_line_item"> Item #<span class="itemNumber">###</span> <!-- do other stuff --> </div> <% end %> What I''m wondering is if there''s a way I can substitute the "###" with an expression that would list the index of the loop (e.g. "1" would be the result for the first iteration, "2" for the second, and so on). Sure there''s an easy way, just don''t know it. Thanks, - 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 -~----------~----~----~----~------~----~------~--~---
On 14 Feb 2008, at 02:04, laredotornado-8iDLEspWrrZBDgjK7y7TUQ@public.gmane.org wrote:> > Hi, > > I have the partial below ... > > <% fields_for "ec_order[ec_line_item_attributes][]", > ec_line_item do |ec_line_item_form| %> > <div class="ec_line_item"> > Item #<span class="itemNumber">###</span> > <!-- do other stuff --> > </div> > <% end %> > > What I''m wondering is if there''s a way I can substitute the "###" with > an expression that would list the index of the loop (e.g. "1" would be > the result for the first iteration, "2" for the second, and so on). > > Sure there''s an easy way, just don''t know it.if you''re rendering a partial foo, then in addition to there being a local variable called foo, there''s also one called foo_counter Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---