How To Skip Rails Validations On Save

Of course this is a bad practice, but once in a while you need to skip validations and callbacks when saving a Rails object.

For my use case today, I needed to go back through existing records and change the values for a few fields. Going forward, there are now new validations to make sure new objects have the correct values for these fields, but going back required skipping these new validations.

Here is how simple it is to skip validations when saving an object in Rails:

my_object.save!(:validate => false)

Remember, with great power comes great responsibility. So use responsibly!

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.