Re: Validating DateHelpers date_select

John Kopanas
Wed, 01 Jun 2005 22:44:29 -0000

validates_inclusion_of :birthdate, :in => Date.new(1900)..
18.years.ago.to_date, :message => "Hey... you are too young... wait
until you turn 18 at least."

18.years.ago.to_date => 1987-06-06

I entered the date: 1978-01-01 00:00:00 -05:00 and I get an error
thrown saying that it does not fall under those two dates.  Does
anyone know why this is happening?


On 26-May-05, at 2:51 PM, Doug Alcorn wrote:

> John Kopanas <john.kopanas-O1KSuMybMhqBUy7/sJONFg@public.gmane.org>
writes:
>
>
>> How would I go about validating that in a rails way.
>>
>
> My solution is like this:
>
>   validates_inclusion_of :dob, :in => Date.new(1930)..
> 18.years.ago.to_date, :message => "Must be born between 1930 and #
> {18.years.ago.strftime(''%Y'')}"
>
> The 1930 thing is kind of arbitrary though, but this doesn''t
require
> extending AR.
> --
> doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org