Forum: Ruby on Rails date_select and impossible dates....

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
olivier Hericord (Guest)
on 2005-12-18 20:35
(Received via mailing list)

using date_select right from a generated scaffold code leads to an
error if an impossible date is selected (like the 31 of february)

can't get a way to correct this via a validation....
in fact that make sens because in the model i have the 'dateofbirth'
object which is a date object....

so providing an impossible day-month-year trio leads to an impossible
creation of the date object...

anyone with a solution?

Ken B. (Guest)
on 2005-12-18 22:02
(Received via mailing list)
I solved this problem by catching the error and displaying it to the
Something similar to the following (off the top of my head, not really
looking at code at the moment):

     # everything ok
    flash[:warning] = "error saving object"
rescue => e
   flash[:warning] = e
render :action=>'new' and return if flash[:warning]
redirect_to :action=>'show', :id=>
This topic is locked and can not be replied to.