Validation: comparing two fields

What is the nicest way to validate the values of
two fields against each other:

For example:

start_date < end_date

where both could be nil.

Stephan

in your model

protected
def validate
errors.add(:end_date, “can’t come before the Start date”) if end_date
< start_date
end

Yes, thanks.

  • Stephan

Josh S. wrote:

in your model

protected
def validate
errors.add(:end_date, “can’t come before the Start date”) if end_date
< start_date
end