Hiya geeks,

So you are done with all the basic stuff and now want to represent your records/information more nicely. Here you go, a simple code to represent alternate row colors for table,paragraph,list. You can modify the code as per your need.There are many other ways, but using cycle is more rails centric code.

Code to be written in view

<% @projects.each do |project| -%>
     <tr class="<%= cycle('oddrow', 'evenrow') %>"> ...... </tr>
<% end %>

Your Stylesheet should look something like this

	table tr.evenrow {background-color: white; }
	table tr.oddrow {background-color: silver; }

Comments are invited.
cheers !!

Realin !

Share this post: