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.
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.
sainaba sainu wrote:
How can I do the validation of date expiry (if the date is lessthan 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs