我想开始使用ror,但这个问题似乎无法解决。我知道有很多关于这个数据库错误的线程,但没有一个解决方案似乎有用。我现在整个下午都在论坛上搜索,没有成功。
我基本上只是从教科书中执行第一项任务,如下所示: 我用
创建了一个新的RoR项目(Windows 10,SQLite3)rails new depot
然后我使用以下代码在此项目中创建一个脚手架:
rails generate scaffold Product title:string description:text image_url:string price:decimal
当我测试应用程序时,我得到db:migrate错误。我尝试了rake db:migrate
,db:rollback
,db:drop
然后db:create
,我检查了迁移文件是否存在错误,但似乎没有任何效果。
我认为解决方案应该非常简单,因为应用程序应该像在这种状态下一样不复杂,但我无法掩盖其出现的秘密。
迁移正在等待处理。要解决此问题,请运行:
bin/rails db:migrate RAILS_ENV=test
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:586:in `load_schema_if_pending!'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:592:in `block in maintain_test_schema!'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:823:in `suppress_messages'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:597:in `method_missing'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activerecord-5.0.1/lib/active_record/migration.rb:592:in `maintain_test_schema!'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_help.rb:15:in `<top (required)>'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
from C:/Users/Flori/Desktop/bsp/test/test_helper.rb:3:in `<top (required)>'
from C:/Users/Flori/Desktop/bsp/test/controllers/products_controller_test.rb:1:in `require'
from C:/Users/Flori/Desktop/bsp/test/controllers/products_controller_test.rb:1:in `<top (required)>'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `require'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:11:in `block in require_files'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/test_requirer.rb:10:in `require_files'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:86:in `plugin_rails_init'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:80:in `block in init_plugins'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:78:in `each'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:78:in `init_plugins'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:129:in `run'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-5.0.1/lib/rails/test_unit/minitest_plugin.rb:73:in `run'
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/minitest-5.10.1/lib/minitest.rb:62:in `block in autorun'
答案 0 :(得分:0)
切换服务器,然后运行
rake db:drop db:create db:migrate
这必须解决您的问题