From 2f332557ee4281a386e09c617e687e5d85968aff Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Wed, 27 Sep 2023 06:35:01 -0500 Subject: [PATCH] Complete Lesson 32 --- app/controllers/sessions_controller.rb | 2 ++ app/controllers/users_controller.rb | 1 + app/views/layouts/_header.html.erb | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 4f4f003..6d0a052 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -14,5 +14,7 @@ class SessionsController < ApplicationController end def destroy + session[:user_id] = nil + redirect_to movies_url, status: :see_other, notice: "You're now signed out!" end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b107d28..a73b63b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -31,6 +31,7 @@ class UsersController < ApplicationController def destroy set_user @user.destroy + session[:user_id] = nil redirect_to movies_url, status: :see_other, alert: "Account successfully deleted!" end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index f6bdbcb..a9b26f4 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -17,6 +17,11 @@ +
  • + <%= link_to "Sign Out", session_path, + data: { turbo_method: :delete }, + class: "button" %> +
  • <% else %>