问题是如何将变量索引的值插入span标记。我有很多提交,我想要显示每个提交的信息。我有以下代码,但它不起作用:
<% @submissions.each do |submission, index| %>
<tr class="athing">
<td align="right" valign="top" class="title">
<span class="rank">index</span>
</td>
<tr>
<% end %>
感谢所有人!
答案 0 :(得分:1)
请尝试以下操作,将index
放入ruby tag
<%= %>
<% @submissions.each_with_index do |submission, index| %>
<tr class="athing">
<td align="right" valign="top" class="title">
<span class="rank"><%=index%></span>
</td>
<tr>
<% end %>