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.



507
508
509
510
511
512
# File 'lib/devise.rb', line 507

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