Reputation: 31
I've tried all night to deploy to Heroku, but I keep getting the same error:
remote: -----> Preparing app for Rails asset >pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Devise.secret_key was not set. Please add the following to your Devise initializer:
remote: config.secret_key = 'secret token string'
remote: Please ensure you restarted your application after installing Devise or setting the key.
...
remote: ! Precompiling assets failed.
remote: !
remote:
remote: ! Push rejected, failed to compile Ruby app
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to viral-blocitoff.
remote:
To https://git.heroku.com/viral-blocitoff.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/viral-blocitoff.git'
I also ran the following to set my environment variable for heroku:
figaro heroku:set -e production
This read all my fixed values, including SENDGRID and DEVISE_SECRET_KEY
Here is my application.yml file (minus the fixed values):
SENDGRID_PASSWORD: ********
SENDGRID_USERNAME: @heroku.com
production:
SECRET_KEY_BASE: secret token
DEVISE_SECRET_KEY: secret token
This is what I have in my devise.rb file:
config.secret_key = ENV['DEVISE_SECRET_KEY']
I looked at other proposed solutions on this site, but I made Devise work on another app less than two months ago without going through such tasks. Is there something I am missing?
Upvotes: 0
Views: 1341
Reputation: 925
My application was reporting the same error, however, the issue results from a combination of using the Figaro gem and rigid systemAdmin. Upon implementing the Figaro gem, creating a secrets.yml file for assigning authentication tokens, then appropriately storing it within .gitignore, a conflict can occur when attempting to deploy to heroku because the .gitignore prevents pushing the secrets.yml file credentials necessary for deployment.
Specifically, I used the following gem and procedure to resolve the conflict.
gem 'heroku_secrets', github: 'alexpeattie/heroku_secrets'
bundle install
git push heroku master --force
The abovementioned solution is explained further in a related StackOverflow post: How do you manage secret keys and heroku with Ruby on Rails 4.1.0beta1?
Moreover, I've encountered multiple issues using Figaro in Rails 4.1; I've detailed problems associated with administration of secrets.yml at the following Gist.
Hopefully this helps-thanks!
Upvotes: 0
Reputation: 31
Got it to deploy. I unset my heroku env variables, then reset them. I also used one token (via ENV variable) for both development and production secret_key_base Pushed remote master to Heroku, it compiled and launched. Then migrated the database too to Heroku. All is well.
Upvotes: 0