Skip to content

Instantly share code, notes, and snippets.

@Jpuelpan
Last active August 29, 2015 14:02
Show Gist options
  • Save Jpuelpan/bac6080497dbd37ecc1a to your computer and use it in GitHub Desktop.
Save Jpuelpan/bac6080497dbd37ecc1a to your computer and use it in GitHub Desktop.
Generate access token
class User < ActiveRecord::Base
def generate_token
self.access_token = loop do
random_token = SecureRandom.uuid
break random_token unless self.class.exists?(access_token: random_token)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment