I'm trying to deploy a Rails 4.2.5 application to a production server using Capistrano 3.4.0. The setup is pretty straightforward, however, on the assets precompile task in capistrano I get the following error:
Devise.secret_key was not set. Please add the following to your Devise initializer:
config.secret_key = '{some generated secret}'
Please ensure you restarted your application after installing Devise or setting the key.
After hours and hours of researching, I've simply done the following:
if Rails.env == 'production'
config.secret_key = ENV['DEVISE_SECRET_KEY']
end
Then I SSH into the server and export the variable. However, when I do cap production deploy I still get the error.
The exact command is:
cd /home/deploy/app/releases/20160402210708 && ( export RAILS_ENV="production" ; ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )
I've read all GitHub issues and StackOverflow answers, but none of them seems to fix my issue, including reinstalling the gem. I've also looked into the devise source code, but according to it what I'm doing should work, so I guess the problem is environment (Capistrano) related. Any hints are appreciated.