我一直在使用arel/rails,並想出瞭如何讓我的group by statement正常工作。使用多列它給出這樣的輸出作爲數組的密鑰散列 - 如何變成一個正常的散列?
{["column1_value","column2_value","column3_value"]=>count,... etc ...}
什麼是最好的/最簡單的方法來將其轉換爲多級哈希?例如
{column1_value:{
column2_value:{
column3_value1: count,
column3_value2: count
}
column2_value2:{ ...}
}
column2_value2: {....}
}
我得到爲什麼結果是由數組鍵入的,但它並不是特別容易使用!
'group_by'是外部AREL。如果它沒有產生預期的結果,你可以隨時做自己的分組。 – tadman