Deploy Ruby on Rails with Capistrano

Asked

Viewed 94 times

0

When executing the deploy I have the following error: Rack app error: #<RuntimeError: Missing 'secret_token' and 'secret_key_bas' for 'production' environment, set these values in 'config/secrets.yml

I’ve made the necessary settings but I can’t find the problem.

I have the set :linked_files, ["#{shared_path}/config/secrets.yml"] in my config/deploy.rb.

I’m using the plugin capistrano-secrets-yml to put my Secrets.yml in the right place:

l shared/config/secrets.yml
lrwxrwxrwx 1 myuser myiser 63 Aug  4 10:44 shared/config/secrets.yml -> /home/myuser/apps/myapp/shared/config/secrets.yml

And I also exported the secret from in my .bashrc -> export SECRET_KEY_BASE=MY_SECRET

And *Secrets.yml` uses this variable:

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

What could be wrong?

  • Already checked if the <%= ENV['SECRET_KEY_BASE'] %> is returning null?

  • I opened on console on my server rails c and while typing ENV['SECRET_KEY_BASE'] is returning the secret correctly. No configuration missing in the pistrano where he’s not getting this variable?

  • 1

    I found the problem, the <%= ENV['SECRET_KEY_BASE'] %> in the Secrets.yml doesn’t work if I put the hash in hand works correctly, but how to take the environment variables.

  • I almost said that kkkkk, good, I took one of my doubts too

1 answer

0

You can solve this problem by adding to Gem dotEnv. Add Gem to your Gemfile in the development group.

Run Bundle; and you’re done! Just create a file .env at the root of your project and pass the environment variables you want to use. For example:

secret_key_base= "234df4r3j43r49..."

And there in the Rails files you use ENV['secret_key_base']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.