L
laredotornado
Hi,
I am creating a variable "counter" to count the number of iterations.
But I get the funny feeling Ruby (I'm using 1.8) may already have some
kind of implicit counter in the loop. Does anyone know of a way the
below can be optimized?
<% counter = 0 %>
<% @ec_orders.each do |ec_order| %>
<tr <%= classify(counter) %>>
<td><%=h ec_order.ship_first_name %></td>
<td><%=h ec_order.ship_last_name %></td>
<td><%=h ec_order.invoice_num %></td>
<td align="center"><%= link_to 'View', {:action => 'view', :id =>
ec_order.id} %></td>
</tr>
<% counter += 1 %>
<% end %>
Thanks, - Dave
I am creating a variable "counter" to count the number of iterations.
But I get the funny feeling Ruby (I'm using 1.8) may already have some
kind of implicit counter in the loop. Does anyone know of a way the
below can be optimized?
<% counter = 0 %>
<% @ec_orders.each do |ec_order| %>
<tr <%= classify(counter) %>>
<td><%=h ec_order.ship_first_name %></td>
<td><%=h ec_order.ship_last_name %></td>
<td><%=h ec_order.invoice_num %></td>
<td align="center"><%= link_to 'View', {:action => 'view', :id =>
ec_order.id} %></td>
</tr>
<% counter += 1 %>
<% end %>
Thanks, - Dave