前提
Rails5.2
Heroku
Herokuで「We're sorry, but something went wrong」が発生。
エラーの内容
Heroku openして、ログインした後、投稿ページに遷移しようとすると、
下記のエラーが発生。
「We're sorry, but something went wrong」
$ heroku logs
でエラー内容チェックすると、下記の内容が表示された。
User Load (1.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
Completed 500 Internal Server Error in 147ms (ActiveRecord: 37.2ms)
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "clips" does not exist..........```
# エラーの説明
```Completed 500 Internal Server Error in...```
=> 内部でエラーが発生している。コードの記述方法に問題がありそう。。。
=> このエラーの**前に記載されているログ**に問題がある!
```Processing by ListingsController#new...```
=> Listings ControllerのNEWアクションに問題がありそう。。。
# エラーの原因であるコード
```app/controllers/listings_controllers.rb
def new
@listing = current_user.listings.new
end
解決策
app/controllers/listings_controllers.rb
def new
@listing = current_user
@listing = Listing.new
end
参考URL