From 49368933cc3fee6e6bae923d38db417e82bdaf8f Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 15 Oct 2014 16:46:36 -0400 Subject: [PATCH] Delete friends --- app/controllers/friendships_controller.rb | 5 +++++ app/views/friendships/index.html.erb | 3 +-- app/views/layouts/application.html.erb | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/friendships_controller.rb b/app/controllers/friendships_controller.rb index e0e6ef8..4c79f15 100644 --- a/app/controllers/friendships_controller.rb +++ b/app/controllers/friendships_controller.rb @@ -18,6 +18,11 @@ class FriendshipsController < ApplicationController end def destroy + @friendship = Friendship.find(params[:id]) + + @friendship.destroy + flash[:success] = 'Friend has been removed from your friends' + redirect_to friendships_path end private diff --git a/app/views/friendships/index.html.erb b/app/views/friendships/index.html.erb index be65d7e..fa9cd4b 100644 --- a/app/views/friendships/index.html.erb +++ b/app/views/friendships/index.html.erb @@ -10,7 +10,6 @@ <% @friendships.each do |friendship| %> - <%= link_to 'Show', friendship %> <%= link_to 'Destroy', friendship, method: :delete, data: { confirm: 'Are you sure?' } %> <% end %> @@ -19,4 +18,4 @@
-<%= link_to 'New Friendship', new_friendship_path %> +<%= link_to 'Add a Friend', users_path %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ce34f14..de81b9e 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,6 +22,10 @@