I wrote in my user model :
def validate
errors.add(:born_on, "is invalid") if Proc.new { |user|
DateTime.parse(user.born_on) }
end
it's wrong I know, running in the console raises an ArgumentError
Loading development environment (Rails 2.3.2)
>> born_on = "99/99/9999"
=> "99/99/9999"
>> DateTime.parse(born_on)
ArgumentError: invalid date
from /usr/local/lib/ruby/1.8/date.rb:1573:in `new_by_frags'
from /usr/local/lib/ruby/1.8/date.rb:1618:in `parse'
from (irb):2
>>
how can I write my validation Proc ?
thanks for your help
erwin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---