遍历数组在最后给出完整的项目数组 [英] Iterating through array gives full array of items at the end
本文介绍了遍历数组在最后给出完整的项目数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试遍历一组记录.然而,在迭代结束时,rails 显示完整的数组.
I am trying to iterate through a set of records. However, at the end of the iteration, rails displays the full array.
<%= @portfolio_item.technologies.each do |technology| %>
<p><%= technology.name %></p>
<% end %>
浏览器中显示的内容
推荐答案
替换这一行
<%= @portfolio_item.technologies.each do |technology|%>
有了这个
<% @portfolio_item.technologies.each do |technology|%>
<%= %>
将计算表达式并返回数组.
<%= %>
will evaluate the expression and returns the array.
这篇关于遍历数组在最后给出完整的项目数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文