If you want to display the list ( of users ) with different css-class for alternate record, there is no need to check the odd-even records,
For this, Rails have awesome feature and that is – ‘cycle’
We can use this as,
say we have 2 css classes-blank and white. If want to apply ‘black’ and ‘white’ class for alternate user record, then we have to write the code as,
<% @users.each do |user| %>
<li class="<%= cycle('black', 'white') -%>">
<%= user.name %></li>
<% end %>
Cool feature