activemodel-immutable_validator

Build Status Code Climate Coverage Status

Validate immutable attributes.

Usage

Add to your Gemfile:

gem 'activemodel-immutable_validator'

Run:

bundle install

Then add the followng to your model which belongs to a user:

validates :attr, immutable: true

Sample

A human cannot become a bot vice versa.

class User < ActiveRecord::Base
  validated :type, immutable: true
end

class Bot < User
end

class Human < User
end