查看打印出整个分贝,不知道为什么
问题描述:
在我看来,我有一个.each循环遍历我的所有图像。代码做我想做的事情。出于某种原因,在所有内容正确显示后,页面底部会出现数据转储。不知道为什么。 这里是我的观点查看打印出整个分贝,不知道为什么
<p id="notice"><%= notice %></p>
<%= @images.each do |image| %> //this causes the data dump, not sure why and how to fix it
<% if image.name == @image.name%>
<p>
<strong>Name:</strong>
<%= image.name %>
</p>
<p>
<strong>Picture:</strong>
<%= image_tag image.picture.url if image.picture %>
</p>
<p>
<strong>Likes:</strong>
<%= image.likes %>
</p>
<%end%>
<%end%>
<%= link_to 'Edit', edit_image_path(@image) %> |
<%= link_to 'Back', images_path %>
答
发生这种情况,因为你会显示您与<%=
标签循环通过对象。为了修正它改变这种
<%= @images.each do |image| %> //this causes the data dump, not sure why and how to fix it
此
<% @images.each do |image| %> //this causes the data dump, not sure why and how to fix it
的[第三连杆(http://*.com/questions/4665279/why-is-this-rails-view-spitting- out-a-raw-array-end-of-each-do-loop?rq = 1)在** Related **侧栏中回答你的问题。 –