Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails3 ActiveRecord::StatementInvalid:... no such table in every test

Tags:

sqlite

ruby

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

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)

Any ideas on fixing this issue?

like image 252
dahpgjgamgan Avatar asked Sep 15 '10 20:09

dahpgjgamgan


2 Answers

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

like image 99
Sauce McBoss Avatar answered Nov 17 '22 02:11

Sauce McBoss


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
like image 33
Shadwell Avatar answered Nov 17 '22 03:11

Shadwell