Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

NYC Standup 08/10/2011: Cycles


  • cycle(even, odd): Jonathan pointed out a method in rails that allows you to apply classes to the even and odd numbered indexes of collections, allowing you to easily apply zebra striping patterns to a collection. Peter mentioned the alternative CSS pseudo-selector “nth-child,” which does the same thing with CSS and properly recalculates in the case where you remove an element with AJAX. Unfortunately, nth-child does not work with IE so if you have to support IE, use cycles, otherwise use nth-child.

  • will_paginate 3.0: Ian mentioned that version 3 of the will_paginate gem was recently released. It now uses scopes, bringing it up to speed with Kaminari, another popular pagination gem.

  • home_run hates ActiveSupport: JT and Micah pointed out that if you’re adding a duration to a DateTime using home_run, like “ +,” it doesn’t play well with ActiveSupport. It assumes that the number on the right is supposed to be days, which it converts to seconds 86,400 and then changes to days again(86,400 days). The ‘+’ operator has been fixed in edge rails, but not yet back ported. They pointed out that although it doesn’t read well, using #since on any instance of DateTime will act how you would hope the ‘+’ operator would.

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *