我正在关注 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
另外,我已登录,因此它应该显示。如果我创建一个新的微博,它将发布给正确的用户。
任何反馈将不胜感激!