Class: ImmutableValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- ImmutableValidator
- Defined in:
- lib/mongoid/validators/immutable_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(object, attribute, value) ⇒ Object
2 3 4 5 6 |
# File 'lib/mongoid/validators/immutable_validator.rb', line 2 def validate_each(object, attribute, value) if object.send(:attribute_changed?, [:field]) and object.send(:attribute_was, [:field]) object.errors.add([:field], 'is immutable and cannot be updated') and false end end |