Re: Validating DateHelpers date_select

John Kopanas
Fri, 27 May 2005 00:13:07 -0000

Come to think of it there is a problem.

<%= 18.years.ago.to_date %>

Displays the correct year and month but gives me the last day of the
month.  Hence you are 18 soon as you enter into the month which
legally is not true :-).  Anyone know why?

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