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


注意!

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



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