0
我有一個艱難的時間搞清楚如何爲我的數組輸出一個html表的助手,這裏是我的數組看起來像。Rails表格的HTML輸出
[
{"day"=>1.0, "hour"=>14.0, "count"=>818.0},
{"day"=>1.0, "hour"=>15.0, "count"=>366.0},
{"day"=>1.0, "hour"=>16.0, "count"=>1246.0},
{"day"=>1.0, "hour"=>17.0, "count"=>116.0},
{"day"=>1.0, "hour"=>18.0, "count"=>434.0},
{"day"=>1.0, "hour"=>19.0, "count"=>123.0},
{"day"=>1.0, "hour"=>20.0, "count"=>442.0},
]
而且這是我的表應該是什麼樣子,我怎麼能每天輸出它的名字在標題,然後每天產量從我的哈希值count
每個小時每個小時?我很難想象如何迭代這些值。
<table>
<tr>
<th style="width:8em"></th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
<th>Sunday</th>
</tr>
<tr>
<th scope="row">00:00–01:00</th>
<td>468</td>
<td>2721</td>
<td>848</td>
<td>3127</td>
<td>803</td>
<td>1970</td>
<td>2673</td>
</tr>
<tr>
<th scope="row">01:00–02:00</th>
<td>468</td>
<td>2721</td>
<td>848</td>
<td>3127</td>
<td>803</td>
<td>1970</td>
<td>2673</td>
</tr>
<!-- remaining hours of the day for each day continue... -->
</table>
任何幫助都會真的很感激。