Answers for "active record validate or"

0

active record validation

class Person < ApplicationRecord
  validates :name, presence: true
end

irb> Person.create(name: "John Doe").valid?
=> true
irb> Person.create(name: nil).valid?
=> false

# List of validation helpers:
# acceptance
# validates_associated
# confirmation
# comparison
# exclusion
# format
# inclusion
# length
# numericality
# presence
# absence
# uniqueness
Posted by: Guest on February-03-2022
0

active record validates

class Person < ApplicationRecord
  validates :name, presence: true
end
Posted by: Guest on December-22-2020

Browse Popular Code Answers by Language