更新时间:2023-11-15 21:50:46
最有可能发生这种情况,因为自定义表名称用于模型(使用set_table_name)或模型在模块中.
Most likely this happens because a custom table name is used for a Model (using the set_table_name) or the model is in a module.
要解决此问题,您需要在fixtures :all
行之前的test_helper.rb
中添加set_fixture_class
行:
To solve, you need to add a set_fixture_class
line in the test_helper.rb
before the fixtures :all
line:
class ActiveSupport::TestCase
self.use_transactional_fixtures = true
.
.
.
set_fixture_class my_table_name: MyModule::MyClass
fixtures :all
end
在这种情况下,灯具文件应名为my_table_name.yml
In this case the fixtures file should be called my_table_name.yml