Skip to content

Instantly share code, notes, and snippets.

@scottwb
Created December 4, 2012 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottwb/4208810 to your computer and use it in GitHub Desktop.
Save scottwb/4208810 to your computer and use it in GitHub Desktop.
# Generate a token by looping and ensuring does not already exist.
def generate_token(column)
loop do
token = Devise.friendly_token
break token unless to_adapter.find_first({ column => token })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment