我有这样的代码:管理优化@视图
<% if @photos.blank? %>
No Pic
<% else %>
<center>
<table>
<tr>
<% @photos.each do |c| %>
<td>
<%= image_tag(url_for({:action => 'image', :id => c.id}),:width =>'20%', :height =>'20%') %><br>
<%= link_to "lihat" , {:action => 'show2', :id => c.id} -%>
<% if logged_in? %>
<small> <%= link_to 'Edit', {:action => "edit2", :id => c.id } %></small>
<small> <%= link_to 'Delete', {:action => "delete2", :id => c.id }, :confirm => "apakah anda yakin mau mengapus berita ini?" %></small>
<% end %>
</td>
<% end %>
</tr>
</table>
</center>
<% end %>
我想打印我的图片“如果列= 5”全自动添加每行
或5图像 输出: [图像] [图像] [图片] [图片] [图片]
我该怎么处理我的代码?请帮我
方式更好的答案比我想(用each_with_index和MOD 5)。很干净! – mixonic 2009-08-06 13:20:45
仍然错误!如果我使用each_with_index作为例子,我该如何输入? – 2009-08-06 19:06:10
你能更具体地了解这个错误吗?它与Array#in_groups_of没有直接关系,然后是Array#each_with_index(我提到的'两种方法'中的第二个;))可能无法帮助你! – 2009-08-07 02:01:03