2016-11-28 58 views
-1

在我看來,我有一個.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 %> 

下面的代碼是一個圖像enter image description here

+0

的[第三連桿(http://stackoverflow.com/questions/4665279/why-is-this-rails-view-spitting- out-a-raw-array-end-of-each-do-loop?rq = 1)在** Related **側欄中回答你的問題。 –

回答

1

發生這種情況,因爲你會顯示您與<%=標籤循環通過對象。爲了修正它改變這種

<%= @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 
相關問題