我目前有一个非常奇怪的问题。我有一个ExportFile
模型。在byebug
测试内部的控制台中,如果我调用.all
,我会看到:
>>> ExportFile.all
#<ActiveRecord::Relation [#<ExportFile id: 189, sequence_number: 1, filename: "DB_EXPORT_20151106173840.zip", status: 3, content: 2, created_at: "2015-12-09 12:54:56", updated_at: "2015-12-09 12:54:56", first_transfer_date: nil, failed_transfer_count: 0, successful_transfer_date: "2015-12-01 12:54:56">, #<ExportFile id: 190, sequence_number: 2, filename: "DB_EXPORT_20151106173840.zip", status: 3, content: 2, created_at: "2015-12-09 12:54:56", updated_at: "2015-12-09 12:54:56", first_transfer_date: nil, failed_transfer_count: 0, successful_transfer_date: "2015-12-01 12:54:56">, #<ExportFile id: 191, sequence_number: 3, filename: "DB_EXPORT_20151106173840.zip", status: 3, content: 2, created_at: "2015-12-09 12:54:56", updated_at: "2015-12-09 12:54:56", first_transfer_date: nil, failed_transfer_count: 0, successful_transfer_date: "2015-12-01 12:54:56">, #<ExportFile id: 192, sequence_number: 4, filename: "DB_EXPORT_20151106173840.zip", status: 3, content: 2, created_at: "2015-12-09 12:54:56", updated_at: "2015-12-09 12:54:56", first_transfer_date: nil, failed_transfer_count: 0, successful_transfer_date: "2015-12-01 12:54:56">, #<ExportFile id: 193, sequence_number: 5, filename: "DB_EXPORT_20151106173840.zip", status: 3, content: 2, created_at: "2015-12-09 12:54:56", updated_at: "2015-12-09 12:54:56", first_transfer_date: nil, failed_transfer_count: 0, successful_transfer_date: "2015-12-01 12:54:56">]>
但如果我尝试.count
, or .all.to_a
,我什么也得不到:
>>> ExportFile.count
0
>>> ExportFile.all.to_a
[]
为什么会发生这种情况,我做错了什么?在运行上面的片段之前,我使用FactoryGirl.create_list(:export_file, 5)
,如果它确实有所作为。