Skip to content

Instantly share code, notes, and snippets.

@decioferreira
Created November 15, 2011 12:02
Show Gist options
  • Save decioferreira/1366911 to your computer and use it in GitHub Desktop.
Save decioferreira/1366911 to your computer and use it in GitHub Desktop.
Rails cycle helper
# Alternate CSS classes for even and odd numbers...
@items = [1,2,3,4]
<table>
<% @items.each do |item| %>
<tr class="<%= cycle("odd", "even") -%>">
<td>item</td>
</tr>
<% end %>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment