Skip to content

Instantly share code, notes, and snippets.

@mergulhao
Created June 8, 2011 14:03
Show Gist options
  • Save mergulhao/1014475 to your computer and use it in GitHub Desktop.
Save mergulhao/1014475 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