1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Heroku] We're sorry, but something went wrong, Completed 500 Internal Server Error, ActiveRecord::StatementInvalid

Posted at

前提

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

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?