2013-03-26 118 views
0

我下面MHartl的書爲Rails 3.2刪除個人資料沒有顯示,而是顯示飼料

在第10章中,他補充說刪除了主頁和個人資料頁

我的問題在微柱鏈接刪除鏈接顯示爲首頁,但不是個人資料頁面。

 <% if current_user?(micropost.user) %> 
      <%= link_to "delete", micropost, method: :delete, 
        confirm: "You sure?", 
        title: micropost.content %> 
     <% end %> 

這是飼料:

 <% if current_user?(feed_item.user) %> 
      <%= link_to "delete", feed_item, method: :delete, 
        confirm: "You sure?", 
        title: feed_item.content %> 
     <% end %> 

這是相同的用戶,所以我不知道爲什麼刪除鏈接將不會顯示。

我的意思是,爲什麼會不顯示的唯一原因是,如果我不籤的,但它顯示了feed_item.user

而且,我所以它應該顯示我簽名。如果我創建了一個新的微博,它會發布給正確的用戶。

任何反饋將不勝感激!

+0

你也許可以調試了一下與顯示user.id只是要100%確定之前。 – mart1nn 2013-03-26 18:08:25

+0

我該怎麼做。感謝您的迴應! – 2013-03-27 02:21:09

+0

您有current_user幫助器方法,只需顯示用戶標識,如'<%= current_user.id%>'(或任何id列被調用),然後爲每個feed_item執行'<%= feed_item.user.id%> '。一般來說,我似乎無法理解爲什麼'current_user?(feed_item.user)'不能工作。唯一可能的原因是當前用戶實際上不是feed_item的所有者。 – mart1nn 2013-03-27 23:05:29

回答

0

同樣的問題也發生在我身上,我固定它通過增加<% current_user %>

相關問題