Max Gee Max Gee - 24 days ago 6
Ruby Question

RubyonRails- You must set config.secret_key_base in your app's config

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

Answer

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