0

when I ssh into the server, and run sudo RAILS_ENV=integration bundle exec rails c I get an error stating Devise.secret_key was not set. Please add the following to your Devise initializer. The secret_key_base is set in the OpsWorks interface as an environment variable. Also, if I simply run sudo bundle exec rails c (which loads the development env) it loads fine because the secrets.yml has hard coded values in the file.

So I guess my question is, how can I verify that my environment variables are making it to the application? When I deployed the app, and output Rails.application.secrets.secret_key_base I get the development secret_key_base, not the one that is loaded in the environment. Or if there is an env variable that doesn't exist in development block in secrets.yml the env variable returns nil Snippet of secrets.yml below.

Thanks for any help/insight!

  integration:                                                                                                                                                                                                                                                                      
    secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
KleverKrypto
  • 518
  • 4
  • 14
  • Take a look at of http://stackoverflow.com/questions/28776805/aws-opsworks-environment-variables-not-working/29080651#29080651 , which I think this is a duplicate of. (In OpsWorks on Rails env variables are set via Passenger, but that's not loaded via rails console) – RyanWilcox Jan 13 '16 at 01:12
  • Thanks, @RyanWilcox I saw that post. I'm trying to refresh the styles via paperclip and when I load the console it doesn't appear to load the api key I have set in OpsWorks. – KleverKrypto Jan 14 '16 at 15:29
  • 1
    Or one way to deal with that is to write out the environmental variables to a file, then source that/file; rails console – RyanWilcox Jan 17 '16 at 13:33

0 Answers0