Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 510
Max Gee Avatar asked Aug 28 '14 02:08

Max Gee


1 Answers

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

like image 66
infused Avatar answered Oct 04 '22 03:10

infused