我正在使用红宝石社交宝石来让人们互相关注。我使用以下?查看当前用户是否跟随该用户的方法。因此,如果他已经跟随用户,他可以取消关注该用户。
<% @users.each do |user| %>
<li>
<div class="user">
<h2>Name - username</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla accumsan enim aliquam, vestibulum orci sed, tincidunt massa. Suspendisse semper ex non egestas tristique. Praesent quis nulla at nunc commodo tincidunt in eget felis. Nunc nec metus non nunc vulputate euismod vel quis elit.</p>
<% if current_user.follows?(user) %>
<button type="button" class="btn btn-default">unfollow</button>
<%else%>
<button type="button" class="btn btn-default">follow</button>
<%end%>
</div>
</li>
<% end %>
Showing /Users/jmurphy/RubymineProjects/sql-ss/app/views/socail_network/user_display/display.html.erb where line #10 raised:
undefined method `follows?' for #<Class:0x007fb6a85dfc80>