I want to create a table such as the below with my data which is stored in Ruby Arrays:
______________________________________________________________
| BUILD | PLATFORM | CATEGORY |
|______________|________________|____________________________|
| | | IP |
| | 8k |____________________________|
| | | UMTS |
| |________________|____________________________|
| 10.0.1.50 | | IP |
| | |____________________________|
| | | UMTS |
| | 9k |____________________________|
| | | Stability |
|______________|________________|____________________________|
| | | IP |
| 10.0.1.51 | 8k |____________________________|
| | | UMTS |
|______________|________________|____________________________|
| | | IP |
| 11.0.1.50 | 9k |____________________________|
| | | UMTS |
|______________|________________|____________________________|
I have the following data in 3 of my arrays:
Arr1
-------------------
row[0] : row[1]
-------------------
11.0.1.50 : 2
10.0.1.51 : 2
10.0.1.50 : 5
Arr2
---------------------------
row[0] : row[1] : row[2]
---------------------------
11.0.1.50 : 9k : 2
10.0.1.50 : 9k : 3
10.0.1.51 : 8k : 2
10.0.1.50 : 8k : 2
Arr3
-------------------------------
row[0] : row[1] : row[2]
-------------------------------
10.0.1.50 : 8k : IP
10.0.1.50 : 8k : UMTS
10.0.1.51 : 8k : IP
10.0.1.51 : 8k : UMTS
10.0.1.50 : 9k : IP
10.0.1.50 : 9k : Stability
10.0.1.50 : 9k : UMTS
11.0.1.50 : 9k : IP
11.0.1.50 : 9k : UMTS
All those numbers in the arrays basically give me a count of the rowspan I might need for that particular entry.
I wrote some code in my rails view, but it does not seem to give me the desired output:
<% @l1_reg.each_with_index do |row1, index1| %>
<table>
<tr>
<!-- Build -->
<td rowspan='<%= row1[1] %>'><strong><%= row1[0] %></strong></td>
<% @l2_reg.each_with_index do |row2, index2| %>
<% if ((row2[0].to_s == row1[0].to_s) %>
<!-- Platform -->
<td rowspan='<%= row2[1] %>'><strong><%= row2[0] %></strong</td>
<% @l3_reg.each_with_index do |row3, index3| %>
<% if ((row3[0].to_s == row2[0].to_s) && (row3[1].to_s == row2[1].to_s)) %>
<!-- Category -->
<td><%= row3[2] %></td>
<% end %>
<% end %>
<% end %>
<% end %>
</tr>
</table>
<% end %>