I was looking for a way to alternate table row colors with Ruby on Rails and stumbled across this gem. All you have to do is use the cycle method on the TextHelper.
<%- for item in @items do -%>
<tr class="<%= cycle("even", "odd") %>">
... use item ...
</tr>
<%- end -%>
and in the css:
.even
{
background: #efefef;
}
.odd
{
background: #a5a5a5;
}
The love affair with Ruby on Rails continues… :)