Skip to content

Instantly share code, notes, and snippets.

@derwiki
Created July 29, 2014 18:51
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 derwiki/5afe027149624288f537 to your computer and use it in GitHub Desktop.
Save derwiki/5afe027149624288f537 to your computer and use it in GitHub Desktop.
User#new_token! to create a new random automatic-login token
def new_token!
SecureRandom.hex(16).tap do |random_token|
update_attributes token: random_token
Rails.logger.info("Set new token for user #{ id }")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment