2024.08.18(更新日: 2024.08.20)
本番環境のlogを確認してエラーを解決していく②

はじめに
自作Railsアプリケーションの一覧画面で起こっているエラーの解決を試みている。

以前、herokuでマイグレーションする方法という記事で、本番環境にデータベースを作成することができた。

警告
SQLiteを本番環境で稼働させることは通常はお勧めできないと警告された。
W, [2024-08-17T05:25:59.272702 #2] WARN -- : You are running SQLite in production, this is generally not recommended. You can disable this warning by setting "config.active_record.sqlite3_production_warning=false".
config.active_record.sqlite3_production_warning=falseという記述でこの警告は無効にできるらしい。
W, [2024-08-17T05:25:59.272702 #2] WARN -- : You are running SQLite in production, this is generally not recommended. You can disable this warning by setting "config.active_record.sqlite3_production_warning=false".
/Users/hiroki/Downloads/money-app/config/environments/production.rbに以下の記述を追記した。

本番環境のエラーは解消されたか?
https://money-app-khiro-a414f54be759.herokuapp.com/posts/index にアクセスした時のエラーは解消されたか?

確認してみると、解消されていないようだった。
heroku logs -a money-app-khiroでログを確認してみると、以下のエラーメッセージが出ていた。
ActionView::Template::Error (SQLite3::SQLException: no such table: posts):
postsテーブルをマイグレーションしたはずなのにおかしい。
考えられる原因
HerokuでSQliteを使用していることが原因と考えられる。
Herokuの公式ドキュメントに、SQLiteは容量の問題で使用できず、その代わりにPostgreを使用してくださいと書いてあった。

PostgreSQLを使用するための具体的な手順は、同公式ドキュメントに書いてある。

次回
PostgreSQLを使用できるようにしていきたい。
投稿ID : 24155
コメントを残す