开发者

Test tableless model in Rails

When I run 'rake test' I get this error:

1) Error: tes开发者_如何学JAVAt_the_truth(DetailsThankYouTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: details: DELETE FROM "details" WHERE 1=1

The application runs fine but I cannot write any simple test. How can I disable Rails test to use the table?


Did you add a fixture file for this model by accident?

According to the testing guide:

Rails by default automatically loads all fixtures from the test/fixtures folder for your unit and functional test. Loading involves (...) removing any existing data from the table corresponding to the fixture.


Presumably you have a class which doesn't have a table itself but which has subclasses which do. In which case you can set:

class Details < ActiveRecord::Base
  self.abstract_class = true
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜