Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Use cover? for validates_inclusion_of with Ranges on 1.9

#6453

Range#include? behaves differently on 1.9 than on 1.8 ( http://rhnh.net/2009/08/03/range-include-in-ruby-1-9 )

In ruby 1.9 include? steps through all the values in the range, checking for equality, this is of course a lot slower, particularly for large ranges, for example date ranges

The old include? logic is available as cover?, which this patch changes validates_inclusion_of to use when checking ranges on 1.9

Reported by Frederick Cheung · February 18th, 2011 @ 06:01 PM

State: committed
Milestone: 3.x
Assigned to: Xavier Noria Xavier Noria
Importance: Low