无法修复 Active Record 待迁移错误

SHA*_*AIN 4 rest activerecord json rspec ruby-on-rails-5

我正在尝试制作一个演示 Restful json api

使用此链接:

https://scotch.io/tutorials/build-a-restful-json-api-with-rails-5-part-one

但是当我尝试运行以下命令时

$ bundle exec rspec

ActiveRecord::PendingMigrationError

error generated

i tried many solution available in stack overflow but no effect happen so far



C:\ruby\imran-api>bundle exec rspec
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:573:in `check_pending!':  (ActiveRecord::PendingMigrationError)

Migrations are pending. To resolve this issue, run:

        bin/rails db:migrate RAILS_ENV=test

        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:586:in `load_schema_if_pending!'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:592:in `block in maintain_test_schema!'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:823:in `suppress_messages'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:597:in `method_missing'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:592:in `maintain_test_schema!'
        from C:/ruby/imran-api/spec/rails_helper.rb:27:in `<top (required)>'
        from C:/ruby/imran-api/spec/controllers/items_controller_spec.rb:1:in `require'
        from C:/ruby/imran-api/spec/controllers/items_controller_spec.rb:1:in `<top (required)>'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
        from C:/Ruby23-x64/bin/rspec:22:in `load'
        from C:/Ruby23-x64/bin/rspec:22:in `<main>'
Run Code Online (Sandbox Code Playgroud)

完整错误图片

pun*_*t18 5

首先运行测试环境的迁移文件:

rails db:migrate RAILS_ENV=test
Run Code Online (Sandbox Code Playgroud)