jeudi 27 novembre 2014

How to double Group-By any attribute or method of ActiveRecord object in Rails


Vote count:

1




I want to make groups of active records by there attributes or there method dynamically for reporting purpose. How can I do that.


Suppose I have Sample ActiveRecord and it has 5 attributes say atr1,atr2,atr3,atr4,atr5and some methods say m1,m2,m3which return different values depending on logic. Now I want to do double grouping of Samplesany attribute or method. i-e Sudo-Code



first groupby atr1 then groupby atr2
first groupby atr4 then groupby m1


these attributes can be dynamic. I'll appreciate a method which will return hash of groups with keys as given attributes/methods value and values as groups founded.


Can somebody help me here please.



asked 2 mins ago







How to double Group-By any attribute or method of ActiveRecord object in Rails

Aucun commentaire:

Enregistrer un commentaire