Class: UnchangeableValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- UnchangeableValidator
- Defined in:
- lib/op_cart/unchangeable_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/op_cart/unchangeable_validator.rb', line 2 def validate_each(record, attribute, value) if !record.new_record? && value.present? if record.changes.include?(attribute) && record.changes[attribute].any? record.errors[attribute] << "cannot be changed once assigned" end end end |