Tag: ruby on rails code example

Validation errors in Ruby on Rails

We’ll look at validation errors in more detail in the Dealing with Validation Errors section. errors.details To check which validation has failed on an invalid attribute, errors.details[:attribute] can be used. It returns an array of hashes with the key :error to get the validator symbol: classPerson < ApplicationRecord   validates :name, presence: true end >>person […]