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