Skip to content

Commit

Permalink
Merge pull request hotsh#668 from carols10cents/config_file_fix
Browse files Browse the repository at this point in the history
Only look for the config file if we're actually going to end up using it
  • Loading branch information
wilkie committed Sep 28, 2012
2 parents 176fd74 + b404c78 commit 000d354
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.

config_file = File.expand_path(File.join(Rails.root, '/config/config.yml'))
config = YAML.load_file(config_file)

if ENV["SECRET_TOKEN"].blank?
if Rails.env.production?
Expand All @@ -15,6 +13,8 @@
# Generate the key and test away
ENV["SECRET_TOKEN"] = RstatUs::Application.config.secret_token = SecureRandom.hex(30)
else
config_file = File.expand_path(File.join(Rails.root, '/config/config.yml'))
config = YAML.load_file(config_file)
# Generate the key, set it for the current environment, update the yaml file and move on
ENV["SECRET_TOKEN"] = config[Rails.env]['SECRET_TOKEN'] = SecureRandom.hex(30)
File.open(config_file, 'w') { |file| file.write(config.to_yaml) }
Expand Down

0 comments on commit 000d354

Please sign in to comment.