Ruby on Rails教程第10章

时间:2013-04-22 05:18:09

标签: ruby-on-rails ruby

我的应用程序能够在我的数据库中找到我的用户表时遇到问题。

rake db:test:prepare并没有为我解决问题。我输入它时没有做任何事情。

Failures:

  1) Micropost
     Failure/Error: let(:user) { FactoryGirl.create(:user) }
     ActiveRecord::StatementInvalid:
       Could not find table 'users'
     # ./spec/models/micropost_spec.rb:5:in `block (2 levels) in <top (required)>'
     # ./spec/models/micropost_spec.rb:8:in `block (2 levels) in <top (required)>'

  2) Micropost
     Failure/Error: let(:user) { FactoryGirl.create(:user) }
     ActiveRecord::StatementInvalid:
       Could not find table 'users'
     # ./spec/models/micropost_spec.rb:5:in `block (2 levels) in <top (required)>'
     # ./spec/models/micropost_spec.rb:8:in `block (2 levels) in <top (required)>'

Finished in 0.00319 seconds
2 examples, 2 failures

Failed examples:

rspec ./spec/models/micropost_spec.rb:13 # Micropost
rspec ./spec/models/micropost_spec.rb:14 # Micropost

2 个答案:

答案 0 :(得分:0)

您必须运行rake db:migrate rake db:test:prepare,如:

rake db:migrate db:test:prepare

答案 1 :(得分:0)

假设您已迁移dev数据库,只需运行rake db:test:clone