MongoID 5汇总:NoMethodError:未定义的方法`[] ': NoMethodError:用于聚合
问题描述:
升级到MongoID 5我得到这个错误后未定义的方法`[]' 为#MongoID 5汇总:NoMethodError:未定义的方法`[] ': NoMethodError:用于聚合
的代码如下所示:
result = ::Presentation::Interaction.collection.aggregate(
[
user_match_criterias_live(conference),
::Presentation::ReportGenerator::DELCOUNTRY_AGGREGATION
]
)
return 0 if (result.count < 1)
return result[0]["total"]
因此,聚合已经使用数组作为参数。
答
在检查包含的结果后,我意识到它不响应[]。但是,它不会响应。首先
的代码看起来像
result = ::Presentation::Interaction.collection.aggregate(
[
user_match_criterias_live(conference),
::Presentation::ReportGenerator::DELCOUNTRY_AGGREGATION
]
)
return 0 if (result.count < 1)
return result.first["total"]