From the course: Ruby on Rails 6 Essential Training: Models and Associations
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Solution: Validations - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training: Models and Associations
Solution: Validations
(upbeat music) - [Lecturer] I hope that you were able to complete this challenge assignment, and that you successfully came up with at least five validations on your own. Whether they were in the simple CMS project or in your own project. In this movie, I'm going to show you some of the validations that I came up with. I started by going into the subject class where we had already added a validation on name. I didn't add anything else to that validation. But I did add two more on position. The position is going to be a number to keep these pages in order. So I said that position should exist, so we'll validate its presence. And then I also validate the numericality and check that it's greater than zero. In page, I added those same two validations. Validates name, with a maximum of 50 for the length, and validates presence of position, making sure it's a number greater than zero. Page also has a permalink…
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.