When you need to toggle the odd or even class names to stripe your table rows, or any similar functionality, you can skip using a counter and checking if its divisible evenly and instead use the Ruby on Rails helper called cycle. It cycles through whatever values are in the supplied argument list each time its called, so it can also be used in other situations. Here is an example for marking your table rows with odd and even classes:

cycle('odd', 'even')