Skip to content

Instantly share code, notes, and snippets.

@slopeofhope81
Created March 20, 2014 16:19
Show Gist options
  • Save slopeofhope81/9667647 to your computer and use it in GitHub Desktop.
Save slopeofhope81/9667647 to your computer and use it in GitHub Desktop.
creating a secret random key using ruby
def secure_token
token_file = Rails.root.join(".secret")
if File.exist?(token_file)
File.read(token_file).chomp
else
token = SecureRandom.hex(64)
File.write(token_file, token)
token
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment