Method: Devise.friendly_token

Defined in:
lib/devise.rb

.friendly_token(length = 20) ⇒ Object

Generate a friendly string randomly to be used as token. By default, length is 20 characters.



492
493
494
495
496
497
# File 'lib/devise.rb', line 492

def self.friendly_token(length = 20)
  # To calculate real characters, we must perform this operation.
  # See SecureRandom.urlsafe_base64
  rlength = (length * 3) / 4
  SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz')
end