Last active
August 29, 2015 14:05
-
-
Save joshmcarthur/b7a6bc99612710f0c8ac to your computer and use it in GitHub Desktop.
Safe assignment of unique token with collision checking
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
def set_access_token | |
begin | |
self.access_token = Devise.friendly_token[0..12] | |
end while ClientForm.exists?(access_token: self.access_token) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment