I have a table with two columns level, and slot. each level can have many slots, but I have made one table that models this case. example
level | slot
1 | 1
1 | 2
1 | 2
2 | 1
2 | 2
2 | 2
and in my erb template I want to make a table that will model this case by making something like a grid.
The issue so far, is I want somethink like two loops to handle this situation. for each level, I get the number of slots and display them. the provided each
loop is not helping. I am thinking of creating a variable that will keep track of the level variable, and when it changes, I call the inner loop. but this does not loop efficient to me.
I am thinking also of creating a json object and make the slots apeats as an array inside the level variable, but I have no idea from where to start this.
or is there a way to write a while loop in the erb template?