Last active
August 29, 2015 14:02
-
-
Save Jpuelpan/bac6080497dbd37ecc1a to your computer and use it in GitHub Desktop.
Generate access token
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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