Validation for : Start date lesser than End date?

Hi,

I have two dates(Start and End date)in my model. How can i do a
validation such as enddate is greater than start date?

Regards,
Sandeep G

Sandeep G. wrote:

Hi,

I have two dates(Start and End date)in my model. How can i do a
validation such as enddate is greater than start date?

Regards,
Sandeep G

before_create

check if this is higher then the other ?

On 9/10/07, Sandeep G. [email protected] wrote:

Hi,

I have two dates(Start and End date)in my model. How can i do a
validation such as enddate is greater than start date?

add your custom validation to the validate method

def validate
errors.add(:start_date, ‘must be earlier than end date’) if
self.start_date > self.end_date
end

Adam