Scope that has three levels deep joins

前端 未结 1 1894
闹比i
闹比i 2021-01-26 06:11

My Program table has many Measures My Measure table has many Targets My Target table has a column called \"

相关标签:
1条回答
  • 2021-01-26 06:33

    What is the target.money of a Program, the sum of all Targets.money of all Measures for this Program ?

    You can try something like:

    Target.order_by( :money => :desc ).map{|target| target.measure }.map{|measure| measure.program }.uniq
    

    Good luck

    0 讨论(0)
提交回复
热议问题