Walk through a list of the different validation methods and helpers available in Ruby on Rails. Learn the syntax for using validates_presence_of, validates_length_of, validates_numericality_of, validates_inclusion_of, validates_exclusion_of, validates_format_of, validates_uniqueness_of, validates_acceptance_of, validates_confirmation_of, and validates_associated.
- [Instructor] In this chapter,…we will learn how to validate data…in Ruby on Rails.…Validations allow us to make sure…that data meets a set of requirements…before it's saved to the database.…You can think of them as rules…that our data must follow.…We could validate data every time…a form is submitted, in other words,…put our validation code in our controllers,…but that would make it so that the rules…are only enforced when we go through…one of those controller actions.…And then we'd be repeating ourselves…every time we had to go through a controller…that made updates to the same database tables.…
It's much better to enforce the rules…all the time globally in our application.…And since this concerns the application's…interaction with the database,…the model is the best place for it.…That way the rules will be enforced…right at the doorway to the database.…So we'll use ActiveRecord::Validations…to define these validation rules…inside our models.…They'll become part of the intelligence…of the model, and can be automatically checked…
- 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.