I'm trying to run my rails in development mode but I'm greeted by this:
Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`
I did a rake secret
and added it to my secrets.yml
production:
secret_key_base: 9c9fc2f9a0a212bb2bc5be64ec3bb722fc5ae01d79c1ed181f1b3a8e858c25f076e7845b67f75ab658947557d81c7fc08ba5bddf20860ec5d681b701be05***
Which results in this message in the browser.
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
So how do I correctly add a secret to my secrets.yml
?
Update
I've created a new secret using rake secret
. Then added it to export SECRET_KEY_BASE=
and ran it. Now when I do echo $SECRET_KEY_BASE
I get the secret I just added. When I visit my localhost I get the We're sorry, but something went wrong. If you are the application owner check the logs for more information.
message.
This is my secrets.yml
development:
secret_key_base: 89dacb16fd905ff4c6352ac93f4676a5dd6e***93edce9a5be796712d54b57b91e1335598fd73e3998fddbbdeaf3ee7f65157f2fb01ce1bea5658aa7bf745d1f
test:
secret_key_base: cf351585b2cb43459f5a073cbfd885b3dd2af44124f13a85552***78c1cf06625c121cd3b7857f86e7fe2ba11180066753142143231c79c513e71e20372a0462
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Update 2
This is shown in my Rails log when I visit the localhost:
I, [2014-11-02T16:24:57.655671 #13782] INFO -- : Started GET "/" for 127.0.0.1 at 2014-11-02 16:24:57 +0100
I, [2014-11-02T16:24:57.670779 #13782] INFO -- : Processing by MoviesController#index as HTML
I, [2014-11-02T16:24:57.694266 #13782] INFO -- : Completed 500 Internal Server Error in 23ms
F, [2014-11-02T16:24:57.697056 #13782] FATAL -- :
ActiveRecord::StatementInvalid (Could not find table 'users'):
app/controllers/application_controller.rb:18:in `current_user'
app/helpers/sessions_helper.rb:26:in `logged_in?'
app/controllers/movies_controller.rb:5:in `index'
Hm, I think I need to create my database in production.
Running RAILS_ENV=production rake db:create db:schema:load
now lets me visit my website, allthough there's no styling etc.
This topic adresses the problem of the no styling. I can now visit and use my App in development on my localhost. Now see if the deployed version works a bit better.