render collection with index

Is there any method for getting the current iteration (for changing row colors) in the category partial?

<%=render(:partial => “category”, :collection => @categories)%>

thanks,
andy

Andrew :

Is there any method for getting the current iteration (for changing row
colors) in the category partial?

<%=render(:partial => "category", :collection => @categories)%>

Use the variable category_counter in your partial.

   -- Jean-François.

Use the variable category_counter in your partial.

– Jean-François.

Thanks so much! I knew there had to be something there…just couldn’t find it.

Andy,

The cycle method is a great way to do this. Here is an example:

<tr class="ListLine<%= cycle(0,1) %>">

Then just style ListLine0 and ListLine1.

Aaron

That is cool. I wish I new that before I wrote my row_class method. :slight_smile:

That is cool. I wish I new that before I wrote my row_class method. :slight_smile:

Also wish I could spell… :wink:

sorry for the extra noise.