Heroku upload-Precompiling assets failed
From the Heroku docs:
This means that your app is attempting to connect to the database as part of rake assets:precompile. Because the config vars are not present in the environment, we use a placeholder DATABASE_URL to satisfy Rails.
To resolve this issue, ensure that the following line appears in your config/application.rb
:
# config/application.rb
config.assets.initialize_on_precompile = false
Once added, commit your change and redeploy to Heroku – your assets should compile without your app attempting to connect to the database, which should resolve the error you're witnessing.
UPDATE:
Line 46 of your stacktrace includes the following message: Devise.secret_key was not set.
According to the author of Devise, José Valim, this issue can be resolved in the following manner:
Please add the following to your Devise initializer:
config.secret_key = '-- secret key --'
Alternatively, the following solution seems to have worked for a number of users:
I went to my routes.rb file and commented out the line devise_for :installs
Then I went back and reran rails generate devise:install. If that doesn't work, use the previous version of devise by editing your Gemfile's reference to Devise like this: gem 'devise', '3.0.3' and then follow the steps i mentioned above.
when you are using github and you are pushing to heroku while you are in develop branch, dont do it, go to master branch and get the updates in the develop by git merge develop
after that,
rails precompile:assets
git add -A
git commit -m "Precompile assets"
git push heroku master
if you want to open the website that you deployed
heroku open
if nothing shows, migrate your database first by:
heroku run rails db:migrate
heroku open
There a few things that solved this issue for me:
# config/application.rb
config.assets.initialize_on_precompile = false
Then, before I deployed, I compiled my assets locally and committed them:
RAILS_ENV=production bundle exec rake assets:precompile
Also, I installed this heroku add on, as was specified by the app I was launching (in my case, Spree commerce)
heroku labs:enable user-env-compile -a myapp
And of course, make sure your database.yml file is set to use adapter: postgresql
.
Commit all of this, push to heroku, and hopefully it will launch. If you still cannot open your app, try looking at the Heroku logs: heroku logs -n 500
I still needed to migrate my database with heroku run rake db:migrate