Sameer Siruguri

My Blog

Rails Tip Of The Day: The Cycle Function

I want to make the rows in my display tables alternate background colors. Guess what? Rails has a function for that.

cycle(first_value, *more_values [with an optional hash at the end with a :name parameter])

The documentation is here: http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-cycle

 

Single Post Navigation

Leave a Reply

Your email address will not be published. Required fields are marked *