Skip to content

Instantly share code, notes, and snippets.

@vajradog
Created December 5, 2013 15:33
Show Gist options
  • Save vajradog/7807567 to your computer and use it in GitHub Desktop.
Save vajradog/7807567 to your computer and use it in GitHub Desktop.
Hiding secret_token.rb on GitHub public repository.
require 'securerandom'
def secure_token
token_file = Rails.root.join('.secret')
if File.exist?(token_file)
# Use the existing token.
File.read(token_file).chomp
else
# Generate a new token and store it in token_file.
token = SecureRandom.hex(64)
File.write(token_file, token)
token
end
end
AppName::Application.config.secret_key_base = secure_token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment