module Randomid::ModelAdditions
Public Instance Methods
unique_identifier(attribute, length=16)
click to toggle source
# File lib/randomid/model_additions.rb, line 4 def unique_identifier(attribute, length=16) before_create do loop do token = Randomid.generate_uid(length) break send("#{attribute}=", token) unless self.class.exists?("#{attribute}" => token) end end end