1
votes

I have a Rails (4.2.1) app that I am deploying to a VPS via Capistrano. I have set the environment variable SECRET_KEY_BASE on the server (in the /etc/environment file). When I run "env" on the server I am able to view the SECRET_KEY_BASE record...

SECRET_KEY_BASE=fa091be2d168da5f943a0a83f9b2...

I have other variables saved in this file as well, such as database username, password, etc. All of these variables are visible when I run "env" on the server.

I have my secrets.yml file set up with the default setting of:

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

Again, I am using environment variables elsewhere... such as my database.yml file:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: <%= ENV['PSQL_DATABASE_USERNAME'] %>
  password: <%= ENV['PSQL_DATABASE_PASSWORD'] %>

When I cap deploy the application, I receive a message stating "Incomplete response received from application". Per review of SO and other sites, I tried to run 'rake secret' on the box and restart the app. Doing this fixed my issue. Oddly enough, all of my database connections and all other references to my ENV variables are working, but for some reason secret_key_base will not accept my ENV variable. As soon as I cap deploy again, my secret key base is wiped out and I'm stuck having to manually SSH the server and 'rake secret' again.

Can anyone help me identify what I'm missing here? I'm racking my brain and scouring the web and can't seem to find my solution.

1
Have you been able to resolve this. I'm running into the exact thing!meta
Sorry, I haven't logged on in a while. Hopefully you've got a solution by now, but in the event that you haven't... what I ended up doing was adding config/secrets.yml to my linked_files on my capistrano deploy. set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml'). Then I created the config/secrets.yml file directly on the server.user3144632

1 Answers

0
votes

try like this

 production:
  secret_key_base: Rails.application.secrets.SECRET_KEY_BASE