Rails3 ActiveRecord :: StatementInvalid:...每个测试都没有这样的表

[英]Rails3 ActiveRecord::StatementInvalid:… no such table in every test


I've started learning rails3 few days ago, and since today, every time I run unit test for my model I get this error message:

我几天前开始学习rails3,从今天起,每次我为我的模型运行单元测试时,都会收到以下错误消息:

ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: users: DELETE FROM "users" WHERE 1=1

ActiveRecord :: StatementInvalid:SQLite3 :: SQLException:没有这样的表:users:DELETE FROM“users”WHERE 1 = 1

The tests went smoothly yesterday, I run them today (reverting everything to the state from the time they were working)... and I'm still getting the error.

昨天的测试顺利进行,我今天运行它们(从他们工作的时间开始恢复到状态)......我仍然得到错误。

I'm using rails 3 release on Windows7 64 bit, SQLite 3.7.2, ruby 187 (but I do have many ruby installations - using pik to select 187)

我在Windows7 64位,SQLite 3.7.2,ruby 187上使用rails 3发行版(但我确实有许多ruby安装 - 使用pik选择187)

Any ideas on fixing this issue?

有关解决此问题的任何想法?

2 个解决方案

#1


11  

It would be worth checking that your test database is set up correctly using the schema from your development database. You can achieve this with:

值得检查是否使用开发数据库中的模式正确设置了测试数据库。你可以用:

rake db:test:prepare

#2


13  

If you created the model using a rails generator, you may have left over fixture files that are trying to access a table that isn't there anymore. For me, deleting the yml file solved the issue.

如果您使用rails生成器创建了模型,则可能遗留了试图访问不再存在的表的fixture文件。对我来说,删除yml文件解决了这个问题。

This was answered here: https://stackoverflow.com/a/6222934

这在这里得到了解答:https://stackoverflow.com/a/6222934

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2010/09/15/720024ba3bbce3dca67e868cccf4677e.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告