How to validate expiry date


#1

Hi

 How can I do the validation of date expiry (if the date is less 

than today) in ruby.Can I do it using the validate method or other def
in the model class?

                         Thanks in advance,
                         Sainaba.

#2

sainaba sainu wrote:

 How can I do the validation of date expiry (if the date is less 

than today) in ruby.

You can do something like this:

def validate
if expiry_date < Date.today
errors.add(:expiry_date , “should be a future date”)
end
end

Eszter