From the course: Ruby on Rails 6 Essential Training: Models and Associations
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
How to skip validations - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training: Models and Associations
How to skip validations
- [Instructor] In this movie, we'll talk about how to skip validations. Skipping validations can be a little bit dangerous. You're going to be bypassing the data rules that you've established for the application. And that should be done with extreme caution because you could actually introduce invalid data into the database and that could have severe consequences to the application, right? You've set rules, you broke the rules and there might be consequences. So don't take skipping validations lightly. That said, if you do need to skip them and sometimes it is helpful to be able to bypass them. You can do that using save and then passing in, validate false. This will then skip the validations while it's saving the record. You can also skip validations while doing an update by using update columns, and then providing a hash of the values that you want to change. Or you can also use update column and provide just a name…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.