user7629374
user7629374

Reputation:

Nginx and Passenger error: Devise secret_key not found

I've just finished setting up a DigitalOcean server and deploying to it via capistrano. Server runs Nginx and Passenger. I'm getting the standard "We're sorry, but something went wrong" from passenger when viewing the IP in browser. nginx & passenger error logs both show:

  <pre>Devise.secret_key was not set. Please add the following to your Devise initializer:<wbr>

  config.secret_key =<wbr> &apos;f9de6853e72cd4e4770bef193e2894ca88be2d8ddd743a917bb3d122631f44b762018158152bfe271876c7ffb4f7c230d8572389423afad1af72c1c7ce6a7191&apos;

Please ensure you restarted your application after installing Devise or setting the key.
 (RuntimeError)

My config/initializers/devise.rb:

  config.secret_key = ENV['SECRET_KEY_BASE'] if Rails.env.production?

and SECRET_KEY_BASE is set as an environment variable on the server. I had an issue in asset compiling during deployment with cap with the same error, and using the environment variable for key worked fine and moved past it.

Any ideas on what's going on are much appreciated!

Upvotes: 0

Views: 123

Answers (1)

user7629374
user7629374

Reputation:

So I found out. For anyone interested it doesn't seem like Passenger sees environment variables in /etc/environment so adding them to ~/.bashrc works.

Thanks!

Upvotes: 1

Related Questions