Skip to content

Instantly share code, notes, and snippets.

@stevedev
Created November 28, 2014 23:32
Show Gist options
  • Save stevedev/91d336cfec8ea53c7646 to your computer and use it in GitHub Desktop.
Save stevedev/91d336cfec8ea53c7646 to your computer and use it in GitHub Desktop.
random token
def generate_unique_token
self.confirmation_token = loop do
random_token = SecureRandom.urlsafe_base64(nil, false)
break random_token unless User.exists?(confirmation_token: random_token)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment