Look at the example below.
1def set_new_api_key! 2 reset_api_key 3 save(validate: false) 4end
When asked why validation was being skipped, the programmer replied that because the user record might be invalid, the api might not be reset.
This attitude is incorrect.
We can't code in an environment of perpetual fear.
We can't code in an environment where we do not trust our data.
We must trust our data and our code to work as they should. Having said that, we need to take precautionary measures, just in case the data is invalid.
In this case, the code should be refactored to
1def set_new_api_key! 2 reset_api_key 3 save! 4end
Now, if the record is invalid, we will receive feedback. We will look over the code and the data and fix whatever necessary.
Do not live in fear - code confidently.
We encourage you to watch Confident Code presentation by Avdi Grimm.