I have a user model with many fields, and I would like to show the table as a matrix of two fields: - created in - type For created_at, I just used group_by like this:
(User.where(:type => "blabla" ).all.group_by { |item|
item.send(:created_at).strftime("%Y-%m-%d") }).sort.each do |
creation_date, users|
This gives me a good array of all users in the creation_date file, so the lines on my table are fine. However, I want to display several rows, each of which is a subset of users for each type. Therefore, at the moment I am doing one query per line (by type, simply replacing "blabla").
This is normal at the moment, because I have only a few types, but this number will increase a lot more soon, and I'm not afraid.
Any suggestion on how I could achieve my expected results?
Thank,
Alex
source
share