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
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@friendship = Friendship.find(params[:id])
|
||||||
|
|
||||||
|
@friendship.destroy
|
||||||
|
flash[:success] = 'Friend has been removed from your friends'
|
||||||
|
redirect_to friendships_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @friendships.each do |friendship| %>
|
<% @friendships.each do |friendship| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to 'Show', friendship %></td>
|
|
||||||
<td><%= link_to 'Destroy', friendship, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
<td><%= link_to 'Destroy', friendship, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -19,4 +18,4 @@
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<%= link_to 'New Friendship', new_friendship_path %>
|
<%= link_to 'Add a Friend', users_path %>
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
<div class="navbar-collapse collapse">
|
<div class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li><%= link_to 'Home', root_path %></li>
|
<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>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<% if current_user %>
|
<% if current_user %>
|
||||||
|
|
Loading…
Reference in a new issue