On Apr 3, 4:29 pm, Jim Burgess <[email protected]>
wrote:
> > You can't easily stop the user entering dates like that with rails
> > built in date helpers, so you need to rescue those exceptions and
> > massage them into a friendly message.
>
> Hi Fred,
> I'm quite surprised, as I would have thought that this makes the entire
> date_select helper open to misuse.

date_select is simple & stupid. Seems to me like the worst case is
someone enters an invalid date and the create fails.

> Nonetheless, two further questions:
>
> How does one rescue exceptons in rails? I just need a point to start.
>
http://www.rubycentral.com/pickaxe/tut_exceptions.html

> Would it be a feasible option to use three text fields in the form that
> are unrelated to the model. Then in the controller string them together
> and make a date object? (that would be more or less how I would do it in
> PHP).

You could. You'd still have to rescue the exception that is raised by
Date::civil when you pass it 2009,2,29 (or do all the bounds checking
yourself)

Fred
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to