I can deploy Heroku, but I get an error and can't open it

environment

We're sorry, but something went wrong.If you are the application owner check the logs for more information.

スクリーンショット 2020-06-11 9.30.00.png

In this way, even if you deploy it, you cannot open it.

solution

The database was the cause. Heroku doesn't default to MySQL, so you have to set it yourself.

These two articles are easy to understand! ↓

--Set with CUI https://qiita.com/senou/items/108ef1d94dcb5b227b4f

--Set by GUI https://qiita.com/poster-keisuke/items/f27e190e22d80dc254ed

After reading these two articles and getting an overview, I set it up with CUI.

Change heroku database to MySQL

[vagrant@localhost memopy]$ heroku addons:create cleardb:ignite
Creating cleardb:ignite on ⬢ memopy... free
Created cleardb-aerodynamic-24825 as CLEARDB_DATABASE_URL
Use heroku addons:docs cleardb to view documentation

[vagrant@localhost memopy]$ heroku config | grep CLEARDB_DATABASE_URL
CLEARDB_DATABASE_URL:     mysql://bc0ee5063e4f00:[email protected]/heroku_fb9e9b74813be35?reconnect=true

[vagrant@localhost memopy]$ heroku config:set DATABASE_URL=mysql2://bc0ee5063e4f00:[email protected]/heroku_fb9e9b74813be35?reconnect=true
Setting DATABASE_URL and restarting ⬢ memopy... done, v7
DATABASE_URL: mysql2://bc0ee5063e4f00:[email protected]/heroku_fb9e9b74813be35?reconnect=true

[vagrant@localhost memopy]$ heroku config
=== memopy Config Vars
CLEARDB_DATABASE_URL:     mysql://bc0ee5063e4f00:[email protected]/heroku_fb9e9b74813be35?reconnect=true
DATABASE_URL:             mysql2://bc0ee5063e4f00:[email protected]/heroku_fb9e9b74813be35?reconnect=true
LANG:                     en_US.UTF-8
RACK_ENV:                 production
RAILS_ENV:                production
RAILS_LOG_TO_STDOUT:      enabled
RAILS_SERVE_STATIC_FILES: enabled
SECRET_KEY_BASE:          57c40cfca095d1fb6419a4e567f5d16f11d3d5827d045def500cff321f31bfa7aefe3ebc740f678ea62a4db48a32f76c7d7569c06295d7aed89d8df62a87b7c4

Now you can use MySQL on heroku!

Asset pipeline settings

It seems that we also have to set up an asset pipeline. If you're looking for an asset pipeline, read this article. ↓ https://www.transnet.ne.jp/2016/02/28/rails%E5%88%9D%E5%AD%A6%E8%80%85%E3%81%8C%E3%81%A4%E3%81%BE%E3%81%9A%E3%81%8Dcolnr%E3%80%8C%E3%82%A2%E3%82%BB%E3%83%83%E3%83%88%E3%83%91%E3%82%A4%E3%83%97%E3%83%A9%E3%82%A4%E3%83%B3/

Looking at config / environments / production.rb,

(Omitted)
config.assets.compile = false
(Omitted)

Because it was

(Omitted)
config.assets.compile = true
(Omitted)

change to.

migration

[vagrant@localhost memopy]$ git add -A

[vagrant@localhost memopy]$ git commit -m 'Asset pipeline settings'

[vagrant@localhost memopy]$ git push

[vagrant@localhost memopy]$ git push heroku master

[vagrant@localhost memopy]$ heroku run rake db:migrate

This completes migrate!

If you open it with heroku open, ...

スクリーンショット 2020-06-11 9.27.28.png

I opened it!

You did it! !! !!

Recommended Posts

I can deploy Heroku, but I get an error and can't open it
I can deploy to heroku, but I get an error and can't open it [Cause: MySQL]
I can't deploy! Resolve an error that can't be pushed to heroku (Rails Tutorial Chapter 1)
I get an error with bundle install and puma cannot be installed.
Where can I get OpenJDK binaries and archives?
I created a Rails post form, but I can't post it (form tag) / No error occurs
Beginner: I get an error on line 30. I don't know where to fix it.
I get an error when adding a dependency
[Mockito] 3.2.4 → 3.3.x, but I got an error (Iketenai)
I built a CentOS 8 environment with Vagrant and tried to sync_folder, but I got an error, so I solved it.
I got an error when using nextInt, nextLine and substring.
When you deploy to Heroku but it doesn't reflect well
[Rails] I can post S3 images in my local environment, but I can't switch to S3 on Heroku.
I can read it! RxJava
I got an error and couldn't push! !! [error: failed to push some refs to]