Skip to content

Instantly share code, notes, and snippets.

@joshmcarthur
Last active August 29, 2015 14:05
Show Gist options
  • Save joshmcarthur/b7a6bc99612710f0c8ac to your computer and use it in GitHub Desktop.
Save joshmcarthur/b7a6bc99612710f0c8ac to your computer and use it in GitHub Desktop.
Safe assignment of unique token with collision checking
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