[RUBY] [Heroku] At the time of deployment We're sorry, but something went wrong. Solution

I built it in a local environment and deployed it on Heroku, but I got this screen. スクリーンショット 2020-12-19 18.43.35.png We're sorry, but something went wrong.

Cause

The development environment (deveropment) was MySQL, but Heroku's standard database is PostgreSQL, but it was still MySQL.

Workaround

Add the following to gem and apply postgreSQL in production environment.

group :production do
  gem 'pg', '>= 0.18', '< 2.0'
end

Bundle install, but add --without production because it is only in the development environment and not needed in the production environment.

$ bundle install --without production

Then edit database.yml. I think it looks like this by default.

database.yml


production:
  <<: *default
  database: <app_name>_production
  username: <app_name>
  password: <%= ENV['<app_name>_DATABASE_PASSWORD'] %>

Rewrite this like this.

database.yml


production:
  adapter: postgresql
  encoding: unicode
  pool: 5
  database: <app_name>_production
  username: <app_name>
  password: <%= ENV['<app_name>_DATABASE_PASSWORD'] %>

After that, do heroku push and don't forget to do heroku run rails db: migrate``` and it's OK!

Recommended Posts

[Heroku] At the time of deployment We're sorry, but something went wrong. Solution
When I deployed it to heroku, "We're sorry, but something went wrong. If you are the application owner check the logs for more information." Stood out.
[Rails] About Uglifier :: Error: Unexpected token: at the time of deployment
Speed comparison at the time of generation at the time of date conversion
[Android] Exit the activity of the transition source at the time of screen transition
About the behavior at the time of error of Files.copy (pathA, pathB)