A common task in business web applications is displaying tables of content in a spreadsheet style format. A nice treatment that adds a lot of usability to such tables of data is visually separating alternating rows of content.
The easiest way to do this in Rails is to use the cycle function as follows:
<%= cycle("odd", "even") %>
Here’s a more full example:
<tr class="<%= cycle("odd", "even") %>"> Row of content </tr>
You could easily use it with any element, such as a div or li.
For more information, please see: