The validates help method provides a shorthand for adding many validations on a single attribute. The validations are the same as the validations in the last movie, but the syntax is shorter and can be faster to write.
- [Narrator] Now that we've taken a look…at the validation methods,…I want to show you another style for writing them.…This is essentially a shortcut…for the validation methods that we just saw.…You'll sometimes here the shortcut style…referred to as sexy validations.…To see what they are, let's first take a look…at a regular validation.…Here we can see that we have five different…validation methods for email:…for validating it's presence,…it's length, it's uniqueness,…it's format, and it's confirmation.…The validates method wraps up all of these…validations on email into one method call like this.…
Now instead of validates presence of email,…I just have validates email and then a hash…telling it what validations I want to use.…So I have one for presence, one for length,…one for uniqueness, one for format,…and one for confirmation.…And each one of those accepts a value along with it,…and that value is the set of options…that we want to pass in for each one.…So guess what it does for each one…of those validations inside this hash?…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.