6
votes

I see all answers for this solution but no worked for me.

1 - My configuration deploy is equal this tutorial by DigitalOcean (Capistrano 3, Nginx, and Puma), with deploy success, i have error in my web:

An unhandled lowlevel error occurred. The application logs may have details.

In log:

Rack app error: #< RuntimeError: Missing secret_token and secret_key_base for 'production' environment, set these values in config/secrets.yml>

2 - In my droplet or VPN, I created variable with a key (rake secret) in file ./bashrc

export SECRET_KEY_BASE=XXXXXX

The file /config/secrets.yml is default

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

With this env variable, i checked than this worked (echo $SECRET_KEY_BASE or printenv | grep SECRET_KEY_BASE)

3 - After Puma and Nginx is restarted and this error not is solved, i not know what is best way to check or debug this error.

Does this tutorial does not work with this solution?

1
maybe my answer doesn't work with capistrano 3, i will remove my answer because for some reason is not working, but maybe you should remove the secrets.yml from your git repo and add it to your host directly, then set the key in the file and avoid the problems with capistrano and environments variablesDemi Magus
i solved making symlink with secret.yml in folder shared (in remote) put the best way is with env variable, I would like to solve this.Adriano Resende
I'm running into this too @AdrianoResende - and I'm tempted to also follow your example. I do believe that the DO guide is outdated so copying it verbatim might be the reason for this error.danielricecodes

1 Answers

0
votes

This is the proper way of handing capistrano env of rails using dotenv-rails gem. The method to use capistrano and env rails in explained in Using Environment Variables in Rails, Heroku, Capistrano