Rails ActiveRecord by-pass validation

ActiveRecord is my favorite way to access a SQL database. It offers very useful validation inside of a model. But sometimes you just want to save an attribute quickly, without validating the whole object. For that you can pass a parameter to the save method.

object.save(:validate => false)

That saved me a lot of time. Awesome!

Published by Robert Reiz

CEO @ VersionEye. Passionated software developer since 1998.

One thought on “Rails ActiveRecord by-pass validation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: