class UnchangeableValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# 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