我有一个 TourDet 模型,其中包含以下持久属性:
tdclientid
tdsuppid
tdpaxnos
tdpriceperpax
我在 TourDet 课程中也有以下内容
def tourval
tdpaxnos * tdpricerperpax
end
我现在正在尝试执行以下操作:
tdis = TourDet.find(:all, conditions: ['tdtourhdrid = 23'], group: [:tdsuppid,:tdclientid], select: ['tdsuppid,tdclientid,sum(tourval) as ttl'])
然而,rails 抱怨 Unknown column 'tourval'。
关于如何以另一种方式实现相同结果的任何想法?
我将 Rails 3.2 与 Ruby 1.9 和 MySQL 一起使用。