Re: Validating DateHelpers date_select

John Kopanas
Fri, 27 May 2005 00:02:27 -0000

Works great.  I set the date arbitrarily to 1899 and make sure my
pulldown menus don''t have anything less then 1900 so I don''t
have to
write in the copy anything about a max age.

I also in my date_select don''t put any years where I am guaranteed to
have people under 18.  This way there is a low chance of someone
selecting a date where they are younger then 18:

date_select("user", "birthdate", :start_year => 1900,
:end_year =>
Date.today.year - 18)

Out of curiosity.  How did you verify the date they did choose was
not an invalid date?  I am having problems with that because we have
to verify it before the object gets created.

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