LoginSignup
3
3

More than 5 years have passed since last update.

rails consoleでDB接続に失敗するようになった

Posted at

備忘録。
突然?rails console時に以下のようなエラーが出るようになった。

irb(main):004:0> User.all
  User Load (0.5ms)  SELECT "users".* FROM "users"
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "users" does not exist
LINE 1: SELECT "users".* FROM "users"

環境変数にDATABASE_URLが設定されている状態で database.yml は以下のような設定。

config/database.yml
development:
  <<: *default
  url: <%= ENV['DATABASE_URL'] %>

rails serverrake task:doでは正常に接続される。
この辺で泣きそうになっていたところ、こんな解決法を見つけて試したらちゃんと動くようになった。

ホッ。

3
3
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
3
3