Date Validation problem

Hello,

I have this validation code in my model.

def validate
errors.add(:last_action_date, "some message") if next_action_date <
last_action_date
end

Two date select fields.

Without the code, as long as dates are valid (no 31st of February), no
errors, works ok.

With the code in place, when the next_action_date is before the
last_action_date then I get a NoMethodError

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.inject

The validation seems to work, but instead of stopping the code and
going back into edit mode like all other rails validations, instead it
gives an error.

Can anyone point me in the right direction?

Thank you,

GPB

To complement my post...

This is the log when the dates pass the validation:

You've left out the stack trace for the actual exception thrown.

Fred

Hi Fred,

I figured it out. Had to do with the placement of the find statements
for creating the arrays in the controller.

They were at the bottom of the "update", when I put them at the top it
solved the problem.

Thank you anyway for answering.

GPB