Database Constraints

Episode #519 by Teacher's Avatar David Kimura

Summary

In this episode, we have a look at two different scenarios where database level constraints are used to ensure the data integrity of our Rails application. The first scenario is more simple and the second one deals with associated records.
rails database validations 13:43

Chapters

  • Introduction (0:00)
  • Database setup (1:27)
  • Creating the User scaffold (2:01)
  • Adding User table constraints (2:19)
  • Adding User model validations (4:11)
  • Testing out the Users (5:38)
  • Creating a has_many scenario (6:50)
  • Adding has_many database constraints (7:29)
  • Adding has_many model validations (8:23)
  • Creating a callback (and warning of them) (9:17)
  • Creating more has_many model validations (9:58)
  • Testing the has_many validations (11:09)
  • Final Thoughts (13:09)
Student & Teacher
$ 9 /mo

Valid School Email Required

Same Access as Pro

Subscribe Now
Pro Monthly
$ 19 /mo

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Pro Annual
$ 190 /yr

Access to Pro Episodes

Invite to Slack Channel

Priority Suggestions

Ad Free

Subscribe Now
Teams
$ 57 /mo

3 Users Minimum

$19.00 / user / month

Same Access as Pro

Subscribe to Teams