我有一个奇怪的错误。当我尝试运行单元测试时,它给了我以下错误:
test_the_truth(UpdateMainTest):
ActiveRecord::StatementInvalid: Could not find table 'blacklists'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:472:in `table_structure'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/sqlite_adapter.rb:346:in `columns'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:660:in `column_names'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:652:in `timestamp_column_names'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:585:in `block in table_rows'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:579:in `each'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:579:in `map'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:579:in `table_rows'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:494:in `block (3 levels) in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:492:in `each'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:492:in `block (2 levels) in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:491:in `block in create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:168:in `disable_referential_integrity'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:476:in `create_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:895:in `load_fixtures'
/var/lib/gems/1.9.1/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:849:in `setup_fixtures'
/var/lib/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:407:in `_run__379848442555604621__setup__3487204981098397389__callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
/var/lib/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/lib/gems/1.9.1/gems/activesupport-3.2.13/lib/active_support/testing/setup_and_teardown.rb:35:in `run'
这是我的黑名单模型:
class Blacklist < ActiveRecord::Base
attr_accessible :abbreviation, :name
self.table_name = "blacklist"
validates :abbreviation, :presence => :true, :uniqueness => :true
validates :name, :presence => :true
end
该架构还正确列出了该表:
create_table "blacklist", :force => true do |t|
t.string "name"
t.string "abbreviation"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
我不止一次运行 rake db:test:prepare,但错误仍然存在。当我使用 rails 控制台时,我可以创建黑名单对象而不会出错。知道我能做什么吗?