Model Validations

Model Validations

Validations ensure data integrity before saving records to the database.

  • validates :title, presence: true
  • validates :email, uniqueness: true

Call valid? or use .save which automatically validates before saving.

Invalid records won’t be saved and will populate errors on the model object.

← PrevNext →