質問編集履歴
2
初心者マークを付けました
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
tarminalに出ているエラー文を追記いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
具体的には、
|
9
|
+
具体的には、Studentsの画面認証後、StudentsのSHOWへリダイレクトを行いたいです。
|
10
10
|
|
11
11
|
|
12
12
|
|
@@ -22,13 +22,73 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
+
```
|
26
|
+
|
27
|
+
Started POST "/students/sign_in" for 127.0.0.1 at 2017-12-06 17:06:42 +0900
|
28
|
+
|
29
|
+
Processing by Students::SessionsController#create as HTML
|
30
|
+
|
31
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"dydoKPbOPys0//hg1RVbSlYo1kroQxipH5osB10RxVSf0JzsDUb/eBFOnTwVjMC01tNOINEQKrVeS6xWdaGwnQ==", "student"=>{"email"=>"aaa@gmail.com", "password"=>"[FILTERED]"}, "commit"=>"ログイン"}
|
32
|
+
|
33
|
+
Student Load (2.8ms) SELECT `students`.* FROM `students` WHERE `students`.`email` = 'aaa@gmail.com' ORDER BY `students`.`id` ASC LIMIT 1
|
34
|
+
|
35
|
+
(0.1ms) BEGIN
|
36
|
+
|
37
|
+
SQL (0.4ms) UPDATE `students` SET `current_sign_in_at` = '2017-12-06 08:06:42', `last_sign_in_at` = '2017-12-06 08:03:06', `sign_in_count` = 7, `updated_at` = '2017-12-06 08:06:42' WHERE `students`.`id` = 2
|
38
|
+
|
39
|
+
(2.3ms) COMMIT
|
40
|
+
|
41
|
+
Redirected to http://localhost:3000/students/2
|
42
|
+
|
43
|
+
Completed 302 Found in 203ms (ActiveRecord: 5.6ms)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
Started GET "/students/2" for 127.0.0.1 at 2017-12-06 17:06:42 +0900
|
50
|
+
|
51
|
+
Processing by StudentsController#show as HTML
|
52
|
+
|
53
|
+
Parameters: {"id"=>"2"}
|
54
|
+
|
55
|
+
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Started GET "/users/sign_in" for 127.0.0.1 at 2017-12-06 17:06:42 +0900
|
62
|
+
|
63
|
+
Processing by Users::SessionsController#new as HTML
|
64
|
+
|
65
|
+
Rendering users/sessions/new.html.haml within layouts/application
|
66
|
+
|
67
|
+
Rendered common/_login_logo.html.haml (4.4ms)
|
68
|
+
|
69
|
+
Rendered devise/shared/_links.html.haml (3.9ms)
|
70
|
+
|
71
|
+
Rendered users/sessions/new.html.haml within layouts/application (20.9ms)
|
72
|
+
|
73
|
+
Rendered common/_header.html.haml (16.3ms)
|
74
|
+
|
75
|
+
Completed 200 OK in 177ms (Views: 176.0ms | ActiveRecord: 0.0ms)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
|
84
|
+
|
25
85
|
###該当のソースコード
|
26
86
|
|
27
87
|
```ruby
|
28
88
|
|
29
89
|
class ApplicationController < ActionController::Base
|
30
90
|
|
31
|
-
before_action :authenticate_user!
|
91
|
+
before_action :authenticate_user!, :authenticate_student!
|
32
92
|
|
33
93
|
protect_from_forgery with: :exception
|
34
94
|
|
@@ -40,9 +100,15 @@
|
|
40
100
|
|
41
101
|
def configure_permitted_parameters
|
42
102
|
|
103
|
+
# sign_inのときに、group_keyも許可する
|
104
|
+
|
43
105
|
devise_parameter_sanitizer.permit(:sign_in, keys:[:group_key])
|
44
106
|
|
107
|
+
# sign_upのときに、group_keyも許可する
|
108
|
+
|
45
109
|
devise_parameter_sanitizer.permit(:sign_up, keys:[:group_key])
|
110
|
+
|
111
|
+
#account_updateのときに、group_keyも許可する
|
46
112
|
|
47
113
|
devise_parameter_sanitizer.permit(:account_update, keys:[:group_key])
|
48
114
|
|
@@ -56,9 +122,9 @@
|
|
56
122
|
|
57
123
|
user_url(resource)
|
58
124
|
|
59
|
-
when
|
125
|
+
when Student
|
60
126
|
|
61
|
-
|
127
|
+
student_url(resource)
|
62
128
|
|
63
129
|
end
|
64
130
|
|
@@ -71,3 +137,9 @@
|
|
71
137
|
どのような記述で上記の仕様を実装すればいいでしょうか。
|
72
138
|
|
73
139
|
ご回答、よろしくお願いいたします。
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
__Completed 401 Unauthorized__のエラーをはいているのですが
|
144
|
+
|
145
|
+
具体的な解決策が見つけ出せません。
|