Delete friends
This commit is contained in:
parent
6f7a044e59
commit
49368933cc
3 changed files with 10 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
Loading…
Reference in a new issue