我試圖以表格的形式在我的模型中顯示對象,但我很難嘗試動態創建行和列。Ruby/Rails - 爲可變數量的單元格動態創建表格
我有一個名爲Pictures的模型,目前我在looooong列表中顯示所有模型。
<% for picture in @pictures %>
<p><%= image_tag(picture.url) %></p>
<% end %>
我怎樣才能把它變成一個表中的軌道與視圖?
<table>
<tr>
<% for picture in @pictures %>
<td>
<%= image_tag(picture.url) %>
</td>
** Here's where I'm confused..How can I write after 6 cells create a new row?? *****
<% end %>
</table>
所以這個問題真的與如何在視圖內分解這種類型的數據有關。
我知道的Ruby/Rails不得不沿着這些路線的東西。儘管如此,我還沒有這樣做,所以從未做過這方面的研究。 –
這看起來比我的答案更好!更可讀。 – drummondj