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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, please search this group because I have answered this question. Good luck, -Conrad On 1/16/07, Joep Mathijssen <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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 > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/validates_date_time/README svn: http://svn.viney.net.nz/things/rails/plugins/validates_date_time 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/howto-validate-date-format-in-ruby-on-rails 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=4740f630-85db-4a4c-b199-8445b345f4f4 If you only want to select dates then you''re better off with date_select: http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#M000469 Kind regards, Mark -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---