From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Write validations

Write validations - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Write validations

- [Instructor] In the previous movie, we learned about Rail's built-in validations. Now, in this movie, we're gonna add validations to our simple CMS project. The first question is, what should we be validating? And to answer this, we need to answer a couple of different questions. What are your data concerns? You need to think about what good data and what bad data looks like. You also should think about the database that you've created. What kinds of restrictions does the database impose on that data? For example, are there certain field types that are required? Certain links that must meet? Is null allowed or not allowed in those database tables? And you should ask yourself, what would stop your application from working? Many times, the things that are going to be validated are a matter of personal style and are going to be different for each and every project. One good way to get started is to review the attributes of each model. By going down the list of attributes, it gives you…

Contents