Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i have an array of activerecord objects, each object has an id and a name. They would look something like this:
- id,name
- 1,red
- 1,green
- 2,red
- 3,yellow
- 4,red
- 4,green
- 4,yellow
- 5,red
- 5,green
- I wish to process them so that firstly they are grouped by their id, with the names concatenated. And then duplicate concatenations are counted, so i would end up with an array:
- count, names
- 2,red green
- 1,red green yellow
- 1 red
- 1,yellow
Add Comment
Please, Sign In to add comment