Guest User

Untitled

a guest
Jul 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. i have an array of activerecord objects, each object has an id and a name. They would look something like this:
  2.  
  3. id,name
  4. 1,red
  5. 1,green
  6. 2,red
  7. 3,yellow
  8. 4,red
  9. 4,green
  10. 4,yellow
  11. 5,red
  12. 5,green
  13.  
  14. 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:
  15.  
  16. count, names
  17. 2,red green
  18. 1,red green yellow
  19. 1 red
  20. 1,yellow
Add Comment
Please, Sign In to add comment