Created
February 14, 2013 19:19
-
-
Save colmtuite/4955490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user.rb | |
def unfollow!(other_user) | |
friendships.find_by_followed_id(other_user.id).destroy | |
end | |
users/show.html.erb | |
<% unless @user == current_user %> | |
<% if current_user.friends_with?(@user) %> | |
<%= form_for current_user.friendships.find_by_followed_id(@user), | |
html: { method: :delete } do |f| %> | |
<%= f.submit "Unfollow" %> | |
<% end %> | |
<% else %> | |
<%= link_to "Follow", friendships_path(:friend_id => @user), :method => :post, class: "btn-sml btn-accent" %> | |
<% end %> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment