1
0
Fork 0

Delete friends

This commit is contained in:
Andrew Tomaka 2014-10-15 16:46:36 -04:00
parent 6f7a044e59
commit 49368933cc
3 changed files with 10 additions and 2 deletions

View file

@ -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

View file

@ -10,7 +10,6 @@
<tbody>
<% @friendships.each do |friendship| %>
<tr>
<td><%= link_to 'Show', friendship %></td>
<td><%= link_to 'Destroy', friendship, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
@ -19,4 +18,4 @@
<br>
<%= link_to 'New Friendship', new_friendship_path %>
<%= link_to 'Add a Friend', users_path %>

View file

@ -22,6 +22,10 @@
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><%= link_to 'Home', root_path %></li>
<% if current_user %>
<li><%= link_to 'Users', users_path %></li>
<li><%= link_to 'Friendships', friendships_path %></li>
<% end %>
</ul>
<ul class="nav navbar-nav navbar-right">
<% if current_user %>