Complete Lesson 32

main
Simon Quigley 1 year ago
parent 8f470ae322
commit 2f332557ee

@ -14,5 +14,7 @@ class SessionsController < ApplicationController
end end
def destroy def destroy
session[:user_id] = nil
redirect_to movies_url, status: :see_other, notice: "You're now signed out!"
end end
end end

@ -31,6 +31,7 @@ class UsersController < ApplicationController
def destroy def destroy
set_user set_user
@user.destroy @user.destroy
session[:user_id] = nil
redirect_to movies_url, status: :see_other, alert: "Account successfully deleted!" redirect_to movies_url, status: :see_other, alert: "Account successfully deleted!"
end end

@ -17,6 +17,11 @@
<li class="nav-item"> <li class="nav-item">
<%= link_to current_user.name, current_user %> <%= link_to current_user.name, current_user %>
</li> </li>
<li>
<%= link_to "Sign Out", session_path,
data: { turbo_method: :delete },
class: "button" %>
</li>
<% else %> <% else %>
<li class="nav-item"> <li class="nav-item">
<%= link_to "Sign In", new_session_path, class: "nav-link" %> <%= link_to "Sign In", new_session_path, class: "nav-link" %>

Loading…
Cancel
Save