Class: ImmutabilityValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ImmutabilityValidator
- Defined in:
- lib/immutability_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, _) ⇒ Object
5 6 7 8 9 |
# File 'lib/immutability_validator.rb', line 5 def validate_each(record, attribute, _) return if record.new_record? record.errors.add(attribute, [:message] || I18n.t('.activerecord.errors.base.immutability')) if record.attribute_changed?(attribute) end |