我正在使用活动记录信誉系统 gem。
我的出发点是显示带有相关投票的企业列表:
@businesses = Business.find_with_reputation(:votes, :all, order: "votes desc")
现在我需要按类别和资产对业务进行分组。
我想显示庄园内某个类别的企业及其相关投票的列表。
所以我有以下模型(多对多)
Business has many Categories through Categorizations
Category has many Businesses through Categorizations
Business has many Estates through Localizations
Estate has many Businesses through Localizations
我可以得到分组的业务
@businesses = @estate.businesses.joins(:categories).where(categories: {id: @category.id})
但我不知道如何获得相关选票。有任何想法吗?