I have a password_reset_token field in my model and it just stores an authentication token which will be used to parse a reset password url.
It’s going to be nil unless the forgot_password method in my controller is called. It’s here the token is generated.
I want a validation to only run here otherwise every time I update a user object validations will complain about the empty token field.
How do I do that?
And why do you want to validate it? When the user goes to the forget password form, he will just have to submit his email address I suppose, and it’s your turn to generate the authentication token, so basically there is no need to validate it as it won’t be an input.