Confirmation of attribute

suggest change

You should use this when you have two text fields that should receive exactly the same content. For example, you may want to confirm an email address or a password. This validation creates a virtual attribute whose name is the name of the field that has to be confirmed with _confirmation appended.

class Person < ApplicationRecord
  validates :email, confirmation: true
end

Note This check is performed only if email_confirmation is not nil.

To require confirmation, make sure to add a presence check for the confirmation attribute.

class Person < ApplicationRecord
  validates :email,      confirmation: true
  validates :email_confirmation, presence: true
end

Source

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


ActiveRecord validations:
*Confirmation of attribute

Table Of Contents
11ActiveRecord validations
55CSV