Reputation: 117
I am trying to go to my localhost and I keep getting the following error in my browser:
You must set config.secret_key_base in your app's config
I have looked around and people say that you have to rake the secret key and then put it into config/initializers/secret_token.rb
but I don't have a secret_token.rb
file in my folder. I am running ruby version ruby 2.1.2p9
and rails version Rails 4.0.8 I am following the tutorial at railstutorial.org
if that helps on 2.2
Upvotes: 5
Views: 6557
Reputation: 76
Rails-5
In rails-5, create config/initializers/secret_token.rb
Add Rails.application.config.secret_key_base= 'secret_token'
where 'secret_token' = rake:secret
Restart the server
Upvotes: 1
Reputation: 24337
Run rake secret
to generate a new token.
Now create a new file config/initializers/secret_token.rb
and add the following:
MyApp::Application.config.secret_key_base = '<token>'
Replace <token>
with the one you just generated and replace MyApp
with the actual module name of your app. You can find the module name of your app at the top of config/environments/development.rb
Upvotes: 18