Class: UnchangedValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- UnchangedValidator
- Defined in:
- lib/auxilium/validators/unchanged_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, _value) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/auxilium/validators/unchanged_validator.rb', line 4 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 |