Institutional Knowledge

Wherein we write down some stuff that we know.

Institutional Knowledge header image 2

Alternating Row Colors with Ruby on Rails

April 12th, 2006 · 2 Comments

It’s as simple as adding this to the class attribute of your table row:

RUBY:
  1. <%= cycle(‘odd’,’even’) %>

In the CSS, just add:

CSS:
  1. .even { background: #efefef; }
  2. .odd { background: #a5a5a5; }

or whatever color you’d like. Ruby on Rails just flat out rocks sometimes.

Technorati Tags: ,

Tags: CSS · Ruby on Rails · Web Design

2 responses so far ↓

  • 1 Michael // Mar 27, 2007 at 2:15 pm

    OK, this blog is almost a year old, but it’s just what I needed.

    Awesome! Thanks :)

  • 2 Lorin Rivers // Apr 5, 2007 at 1:18 pm

    It’s the little things. Thanks for this tip!