Class: ImmutableValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ImmutableValidator
- Defined in:
- lib/immutable_validator.rb,
lib/immutable_validator/engine.rb
Defined Under Namespace
Classes: Engine
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, _value) ⇒ Object
2 3 4 5 6 |
# File 'lib/immutable_validator.rb', line 2 def validate_each(record, attribute, _value) return if record.new_record? return unless record.public_send("#{attribute}_changed?") record.errors.add(attribute, [:message] || :immutable) end |