Ruby on rails 3 循环视图的轨道
我有以下代码:Ruby on rails 3 循环视图的轨道,ruby-on-rails-3,Ruby On Rails 3,我有以下代码: <tbody> <%= Item.each do |item|=%> <tr> <th><%= item.rev =%></th> <========= <th><%= item.name =%></th> </tr> <%= end =%> </tbody> 你的等号是
<tbody>
<%= Item.each do |item|=%>
<tr>
<th><%= item.rev =%></th> <=========
<th><%= item.name =%></th>
</tr>
<%= end =%>
</tbody>
你的等号是错误的。请尝试以下操作:
<tbody>
<% Item.each do |item|%>
<tr>
<th><%= item.rev %></th>
<th><%= item.name %></th>
</tr>
<% end %>
</tbody>
erb标签的表达为
现在,如果我们也想打印该标签,那么我们将应用
i、 e.只使用一个“=”符号,左侧也使用该符号。
此外,在每个迭代器的行中,没有任何内容可以打印,因此没有“=”登录
该行与包含“end”的标记的情况类似。
因此,您的代码应该看起来像