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:


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 个解决方案



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



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.


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




ActiveRecord :: StatementInvalid:找不到表 - ActiveRecord::StatementInvalid: Could not find table Rails3 Mysql2::錯誤:未知列- ActiveRecord::StatementInvalid。 - Rails3 Mysql2::Error: Unknown column - ActiveRecord::StatementInvalid rake流產!ActiveRecord:::StatementInvalid: SQLite3::SQLException:沒有這樣的表:耙子自動化難以工作 - rake aborted! ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: Trouble Getting Rake Automation to Work Rails ActiveRecord :: StatementInvalid:PG :: Error:ERROR:缺少表的FROM子句條目 - Rails ActiveRecord::StatementInvalid: PG::Error: ERROR: missing FROM-clause entry for table ActiveRecord :: StatementInvalid:PG :: SyntaxError(Ruby Rake測試) - ActiveRecord::StatementInvalid: PG::SyntaxError (Ruby Rake test) ActiveRecord::StatementInvalid SQLite3::SQLException:沒有這樣的列:true: - ActiveRecord::StatementInvalid SQLite3::SQLException: no such column: true: rails/mysql -我如何屏蔽ActiveRecord: StatementInvalid error? - rails/mysql - how do i silence out ActiveRecord::StatementInvalid error? Rails測試錯誤:沒有這樣的表:files_users:DELETE FROM“files_users” - Rails test error: no such table: files_users: DELETE FROM “files_users” 更新不同表中的列Rails3 - Update column in different table, Rails3 Ruby on Rails / ActiveRecord和表分區 - Ruby on Rails / ActiveRecord and Table Partitions
粤ICP备14056181号  © 2014-2020 ITdaan.com