LoginSignup
0
0

More than 5 years have passed since last update.

ActiveRecord::PendingMigrationError が表示されたら

Posted at

エラー画面が出る前の経緯

ユーザー情報を管理するデータベースにアクセスするためのモデルクラスを作成しようと思い、
usersテーブル(ユーザー情報を管理する)と、usersテーブルに対応する Userクラス を作成した。

$ rails generate model user name:string email:string password:string image:string comment:text

すると

Running via Spring preloader in process 2710
      invoke  active_record
      create    db/migrate/20190205145217_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/models/user_test.rb
      create      test/fixtures/users.yml

と返ってきて、無事作成されたようである。

再度、Railsを起動して作成中のページを更新したところ、
以下のようなエラー画面が出てきた!

エラー画面

スクリーンショット 2019-02-06 10.14.12のコピー.png

以下のコマンドで、マイグレートしてテーブルを作成

$ bundle exec rails db:migrate

再起動すると、無事エラーが解消された。

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