teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ログアウト処理のコントローラを明示、ログアウト時のエラーログを明示

2021/10/26 10:36

投稿

yg4yoYYLOO7pqB9
yg4yoYYLOO7pqB9

スコア2

title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,35 @@
11
11
  ```
12
12
  ActionController::RoutingError (No route matches [GET] "/logout"):
13
13
  ```
14
-
14
+ ec2サーバー上でsudo tail -f log/production.logを実行した結果です
15
+ ```
16
+ [2021-10-26T10:33:48.373111 #26769] INFO -- : [1860493b-41b3-4d0f-9b7e-e62894e7414d] Started GET "/logout" for 180.149.181.188 at 2021-10-26 10:33:48 +0000
17
+ F, [2021-10-26T10:33:48.373638 #26769] FATAL -- : [1860493b-41b3-4d0f-9b7e-e62894e7414d]
18
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] ActionController::RoutingError (No route matches [GET] "/logout"):
19
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d]
20
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] actionpack (6.0.3) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call'
21
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] actionpack (6.0.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
22
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] railties (6.0.3) lib/rails/rack/logger.rb:37:in `call_app'
23
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] railties (6.0.3) lib/rails/rack/logger.rb:26:in `block in call'
24
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] activesupport (6.0.3) lib/active_support/tagged_logging.rb:80:in `block in tagged'
25
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] activesupport (6.0.3) lib/active_support/tagged_logging.rb:28:in `tagged'
26
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] activesupport (6.0.3) lib/active_support/tagged_logging.rb:80:in `tagged'
27
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] railties (6.0.3) lib/rails/rack/logger.rb:26:in `call'
28
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] actionpack (6.0.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
29
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] actionpack (6.0.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
30
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] rack (2.2.3) lib/rack/method_override.rb:24:in `call'
31
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] rack (2.2.3) lib/rack/runtime.rb:22:in `call'
32
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] activesupport (6.0.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
33
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] actionpack (6.0.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
34
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
35
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] actionpack (6.0.3) lib/action_dispatch/middleware/host_authorization.rb:76:in `call'
36
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] railties (6.0.3) lib/rails/engine.rb:527:in `call'
37
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] puma (4.3.6) lib/puma/configuration.rb:228:in `call'
38
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] puma (4.3.6) lib/puma/server.rb:713:in `handle_request'
39
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] puma (4.3.6) lib/puma/server.rb:472:in `process_client'
40
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] puma (4.3.6) lib/puma/server.rb:328:in `block in run'
41
+ [1860493b-41b3-4d0f-9b7e-e62894e7414d] puma (4.3.6) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
42
+ ```
15
43
  ### 該当のソースコード
16
44
 
17
45
  ```ruby
@@ -24,6 +52,21 @@
24
52
  require("channels")
25
53
  require('jquery')
26
54
  ```
55
+ ログアウト処理のコントローラ
56
+ ```
57
+ def destroy
58
+ log_out if logged_in?
59
+ redirect_to root_path
60
+ end
61
+ ```
62
+ log_outメソッド
63
+ ```
64
+ def log_out
65
+ forget(current_end_user)
66
+ session.delete(:end_user_id)
67
+ @current_end_user = nil
68
+ end
69
+ ```
27
70
 
28
71
  ### 試したこと
29
72