Sha256: 22bcf3150fa7b5c6d971d642ee8248393966da3855d73fb287311387ab935909
Contents?: true
Size: 402 Bytes
Versions: 3
Compression:
Stored size: 402 Bytes
Contents
# frozen_string_literal: true class UnchangedValidator < ActiveModel::EachValidator def validate_each(record, attribute, _value) return unless record.persisted? if record.changed_attributes.include?(attribute) || record.changed_attributes.include?("#{attribute}_id") record.errors.add(attribute, I18n.t('errors.messages.may_not_be_changed')) end end end
Version data entries
3 entries across 3 versions & 1 rubygems