After 24 hours of trying to find the problem with my app. I finally found the problem.
I ran
rake assets:precompile RAILS_ENV=production
What worked for me was this:
rake assets:precompile RAILS_ENV=production
Access your server via ssh and type that command in, it should do the trick.
call rake assets:precompile:all
Do this:
development:
adapter: postgresql
host: localhost
encoding: unicode
database: ndoda_development
pool: 5
username:
password:
test:
adapter: postgresql
encoding: unicode
database: ndoda_test
pool: 5
# Add the below...
production:
adapter: postgresql
host: localhost
encoding: unicode
database: ndoda_production
pool: 5
username:
password:
Heroku will overwrite your database.yml with its own version, regardless of what you put in there. However, your rake task running in the Production environment requires a variable, so give it a dummy one.
As noted above, you can also add 'config.assets.initialize_on_precompile = false' to your production.rb. If set, Heroku requires it be set to 'false'.
This should work: rake assets:precompile RAILS_ENV=development
It tries to load up your production environment, when your database.yml doesn't include it.
The simple solution was to add one simple line to my application.rb
config.assets.initialize_on_precompile = false
And everything works.
Make sure you have some dummy production
entry in your local config/database.yml
file
production:
<<: *default
database: your_local_database_name
I've come across the same error in 2016 with Rails 4.2.6 and Capistrano 3.4. We were precompiling the assets during the deploy script just before uploading them together with the code, but rake assets:precompile needs some production entry, even if it's just a dummy one. Source: https://github.com/TalkingQuickly/capistrano-3-rails-template/issues/12