ruby - Rails: Group result set by combination of multiple columns -
i have table called negotiations this
id seller_id buyer_id property_id 1 4 190 33123 2 4 190 33123 3 5 191 34000 4 5 191 34000 5 6 200 35000 i can fetch doing negotiation.all
i want fetch everything, grouped seller_id-buyer_id-property_id combination. in above example want return 3 groups.
is possible in rails application?
you can use enumerable#group_by :
negotiation.all.group_by{|x| [x.seller_id, x.buyer_id, x.property_id]}
Comments
Post a Comment