On 24 February 2010 10:21, Pale Horse <[email protected]> wrote: > Michael Pavling wrote: >> try it and see :-) > > I just fail to see why my method wouldn't work, but I will try - thank > you.
You're doing a regex evaluation on a Date (or DateTime) object... so it fails. Try these in IRB: >> Date.today =~ /10/ >> Date.today.to_s =~ /10/ By definition, the format of the Date converted to a string is defined by the to_s method, so it's a tautology to change it to a string and check its format! By all means check that it's in the future or past, or within whatever range you want... but it's a DATE - so do date operations on it, not string operations. If you want to check what the user *typed* you need to get to the controller and do some validation on params[:closing_date] (or pass that value into an attr_writer in your model, and do model validations on that parameter...) -- 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.

