質問編集履歴
2
書式の改善
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
devise
|
1
|
+
deviseで登録情報がsaveできない
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
deviseを導入して、複数モデルを作成し、ログインを実行したところ
|
8
8
|
|
9
|
-
|
9
|
+
保存がされていませんでした。通常通りログインができるようにしたいです。
|
10
10
|
|
11
11
|
初学者ゆえ、もろもろ抜けているところなどありましたら、ご指摘いただければと思います。
|
12
12
|
|
@@ -18,37 +18,65 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
21
|
+
ターミナル
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Started POST "/speakers" for ::1 at 2020-10-01 14:33:00 +0900
|
26
|
+
|
27
|
+
Processing by Speakers::RegistrationsController#create as HTML
|
28
|
+
|
29
|
+
Parameters: {"authenticity_token"=>"cMpj1qCQPUrcY8s44bXNgiKuqAIsaUdlQThsr0H4h63nFNKe+8+r6dMc5ewH/vLk5iIJxh1vj86UWztsmmKRVg==", "speaker"=>{"nickname"=>"wa", "email"=>"wa@wa", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "first_name"=>"あ", "last_name"=>"あ", "first_name_kana"=>"ア", "last_name_kana"=>"ア", "birth_date(1i)"=>"1931", "birth_date(2i)"=>"6", "birth_date(3i)"=>"5"}, "commit"=>"会員登録"}
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
From: /Users/yuuri/projects/wacca/app/controllers/speakers/registrations_controller.rb:15 Speakers::RegistrationsController#create:
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
13: def create
|
38
|
+
|
39
|
+
14: @speaker = Speaker.new(speaker_signup_params)
|
40
|
+
|
41
|
+
=> 15: binding.pry
|
42
|
+
|
43
|
+
16: if @speaker.save
|
44
|
+
|
45
|
+
17: redirect_to root_path
|
46
|
+
|
47
|
+
18: else
|
48
|
+
|
49
|
+
19: render :new
|
50
|
+
|
51
|
+
20: end
|
52
|
+
|
53
|
+
21: end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
[1] pry(#<Speakers::RegistrationsController>)> @speaker
|
58
|
+
|
59
|
+
=> #<Speaker id: nil, first_name: nil, last_name: nil, first_name_kana: nil, last_name_kana: nil, nickname: "", email: "", birth_date: nil, created_at: nil, updated_at: nil>
|
60
|
+
|
61
|
+
[2] pry(#<Speakers::RegistrationsController>)>
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
コントローラー
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
# frozen_string_literal: true
|
46
74
|
|
47
75
|
|
48
76
|
|
49
77
|
class Speakers::RegistrationsController < Devise::RegistrationsController
|
50
78
|
|
51
|
-
before_action :
|
79
|
+
before_action :speaker_signup_params, only: [:create]
|
52
80
|
|
53
81
|
# before_action :configure_account_update_params, only: [:update]
|
54
82
|
|
@@ -56,18 +84,30 @@
|
|
56
84
|
|
57
85
|
# GET /resource/sign_up
|
58
86
|
|
59
|
-
|
87
|
+
def new
|
60
|
-
|
88
|
+
|
61
|
-
|
89
|
+
@speaker = Speaker.new
|
62
|
-
|
90
|
+
|
63
|
-
|
91
|
+
end
|
64
|
-
|
65
|
-
|
66
|
-
|
92
|
+
|
93
|
+
|
94
|
+
|
67
|
-
# POST /resource
|
95
|
+
# POST /resource
|
68
96
|
|
69
97
|
def create
|
70
98
|
|
99
|
+
@speaker = Speaker.new(speaker_signup_params)
|
100
|
+
|
101
|
+
if @speaker.save
|
102
|
+
|
103
|
+
redirect_to root_path
|
104
|
+
|
105
|
+
else
|
106
|
+
|
107
|
+
render :new
|
108
|
+
|
109
|
+
end
|
110
|
+
|
71
111
|
end
|
72
112
|
|
73
113
|
|
@@ -120,15 +160,15 @@
|
|
120
160
|
|
121
161
|
|
122
162
|
|
123
|
-
|
163
|
+
protected
|
124
164
|
|
125
165
|
|
126
166
|
|
127
167
|
# If you have extra params to permit, append them to the sanitizer.
|
128
168
|
|
129
|
-
def
|
169
|
+
def speaker_signup_params
|
130
|
-
|
170
|
+
|
131
|
-
devise_parameter_sanitizer.permit(:sign_up, keys: [:
|
171
|
+
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name,:last_name,:first_name_kana,:last_name_kana,:email,:nickname,:birth_date])
|
132
172
|
|
133
173
|
end
|
134
174
|
|
@@ -164,16 +204,6 @@
|
|
164
204
|
|
165
205
|
end
|
166
206
|
|
207
|
+
|
208
|
+
|
167
|
-
```
|
209
|
+
```
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
### 試したこと
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
下記のサイトを参考にコントローラーの作成を行いました。
|
176
|
-
|
177
|
-
https://qiita.com/kinpin/items/21b1badcfe19aca84038
|
178
|
-
|
179
|
-
https://qiita.com/Yama-to/items/54ab4ce08e126ef7dade
|
1
タイトルの編集
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
devise(複数モデル)のログイン
|
1
|
+
devise(複数モデル)のログインを実装したい
|
test
CHANGED
File without changes
|