I do it myself:
validates_numericality_of :mileage,:if => Proc.new {|car| car.mileage.present? }
Sometimes the mileage field may not be sent, but when it is, I want it to be checked. I have no problem with Proc inside my code, but this is the code that I duplicate for all other optional fields. Is there a shortcut, for example :if => present?? I am using Rails 3.0.5.
source
share