record = #<ActiveRecord::AssociationRelation
[#<User id: 2, store_id: 3,location: 'xxx'>,
#<User id: 4, store_id: 3,location:'yyy'>,
#<User id: 5, store_id: 4,location:'zzz'>,
#<User id: 6, store_id: 4,location:'aaa'> ]>
如何组位置以逗号分隔的形式基础上红宝石STORE_ID得到的结果,活动记录分组在Ruby on Rails的
商店中的ID(3)的位置应与逗号combained如(YYY,XXX),
然后商店中的ID(4)的位置应与逗号combained为(ZZZ,AAA)
#< store_id: 3,location:'yyy,xxx'>
#< store_id: 4,location:'zzz,aaa'>
要组究竟如何?通过'store_id',通过'location'或者两者兼而有之?你的问题并不清楚。 –
你实际上是要求一个'sort'而不是'group'吗?从你提供的小信息看,你想要一个排序。 – Beartech
我需要由store_id分组 – Dheena