module RandomizedField

Top-level module that adds the randomized_field method to ActiveRecord objects. Include in individual models or ApplicationRecord.

Constants

VERSION

Public Instance Methods

randomized_field(field_name, **opts, &block) click to toggle source
# File lib/randomized_field.rb, line 13
def randomized_field(field_name, **opts, &block)
  before_create RandomizedField::Callback.new(field_name, **opts, &block)
  validates field_name, uniqueness: true
end