We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 045fbef commit 416c16eCopy full SHA for 416c16e
config/initializers/secret_token.rb
@@ -9,4 +9,20 @@
9
10
# Make sure your secret_key_base is kept private
11
# if you're sharing your code publicly.
12
-Solar::Application.config.secret_key_base = '05f631010699c16c9768e141afce8173bc48c89207ee20599e2fc5489c725111b4f14f70b078a23cb673940c59f914a78577f4818ccf5812b955ea18a9b906f1'
+
13
+require 'securerandom'
14
15
+def secure_token
16
+ token_file = Rails.root.join('.secret')
17
+ if File.exist?(token_file)
18
+ # Use the existing token.
19
+ File.read(token_file).chomp
20
+ else
21
+ # Generate a new token and store it in token_file.
22
+ token = SecureRandom.hex(64)
23
+ File.write(token_file, token)
24
+ token
25
+ end
26
+end
27
28
+Solar::Application.config.secret_key_base = secure_token
0 commit comments