Active Storage Validators

Episode #399 by Teacher's Avatar David Kimura

Summary

Validation of files that are uploaded can provide a better user experience as it sets the expectations of what kinds of files, their sizes and if they're even required. In this episode, we'll look at creating different types of validators for Active Storage.
rails active storage validations 14:25

Chapters

  • Introduction (0:00)
  • Setting up Active Storage (0:57)
  • Adding variants (1:58)
  • Add image_processing gem (2:41)
  • Make sure Active Storage is working (2:56)
  • Validation - Presence (3:18)
  • Validation - Content Type (3:48)
  • Validation - File Size (7:32)
  • Demo of all validators (9:39)
  • Updating the Content Type Validator (9:56)
  • Final thoughts (12:28)
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