Forum: Ruby on Rails datetime_select validation

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cfc568b0df901e83ea3c22247fa017bc?d=identicon&s=25 Joep Mathijssen (joepmath)
on 2007-01-16 09:14
I'm using a datetime_select. When I select an invalid date like 31
february 2007 it's received by the model as 3 march 2007. I would like
to generate a nice error for the user, but the only option I see now is
hack this into the controller. Not so nice...

Joep Mathijssen
520c24bad2fa9b171d022e3600cd5e58?d=identicon&s=25 Mark Noten (mnoten)
on 2007-01-16 11:15
Hi Joep,

if you're using datetime_select to set a DateTime property in your
model, then you might want to consider using the pluging from Jonathan
Viney available at:

readme:
http://svn.viney.net.nz/things/rails/plugins/valid...
svn: http://svn.viney.net.nz/things/rails/plugins/valid...

This plugin can validate dates and times with some extra constraints
(:before, :after, ...) for properties of your model. There are some
small examples at:

http://www.railsonwave.com/railsonwave/2006/12/13/...

You may want to replace the parse_date function in parser.rb with the
one from Matt Griffith explained at:

http://mattgriffith.net/Permalink.aspx?guid=4740f6...

If you only want to select dates then you're better off with
date_select:

http://api.rubyonrails.org/classes/ActionView/Help...

Kind regards,

Mark
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (Guest)
on 2007-01-16 11:44
(Received via mailing list)
Hi, please search this group because I have answered this question.

Good luck,

-Conrad
This topic is locked and can not be replied to.