You would want each_with_index.

<ul>

  <% @recipie.steps.each do |step, index| %>

    <li><%= index %>: <%= step.step %></li>

  <% end %>

</ul>


A little cleaner, and handles updating the index for you.

-Steve

On Sun, Jan 3, 2010 at 12:47 PM, Ooh_Gravy <[email protected]> wrote:

> So answering my own question, is this ok or is there a cleaner way to
> do it?
>
>        <ul>
>                <% index = 1 %>
>                 <% @recipe.steps.each do |step| %>
>                         <li><%= index %>: <%= step.step %></li>
>                        <% index += 1 %>
>                <% end %>
>        </ul>
>
> Thanks a lot.
>
> On Jan 3, 5:10 pm, Ooh_Gravy <[email protected]> wrote:
> > OK, thanks.  What I wanted to do was this:
> >
> >         <ul>
> >                 <% @recipe.steps.each do |step| %>
> >                         <li><%= step.id %>: <%= step.step %></li>
> >                 <% end %>
> >         </ul>
> >
>
> --
>
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>

--

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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to