質問編集履歴
5
コード形式で載せました
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,24 +2,238 @@
|
|
2
2
|
|
3
3
|
おそらくusernameというカラムがdefaultで存在しないために起きているエラーだと思われるのですが、これはどのファイルをどのように修正すればよいでしょうか?
|
4
4
|
|
5
|
-
|
6
|
-
|
7
5
|
![イメージ説明](58cc696a1261388608ec8e057a7d4a14.png)
|
8
6
|
|
9
7
|
ログイン時のview
|
10
8
|
|
9
|
+
```
|
10
|
+
|
11
|
+
.log
|
12
|
+
|
13
|
+
.login
|
14
|
+
|
15
|
+
%h2.login-header aaaaa
|
16
|
+
|
17
|
+
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
|
18
|
+
|
19
|
+
.field
|
20
|
+
|
21
|
+
-# = f.label :ユーザ名
|
22
|
+
|
23
|
+
%br/
|
24
|
+
|
25
|
+
= f.email_field :email, autofocus: true, autocomplete: "email",placeholder: "メールアドレス"
|
26
|
+
|
27
|
+
.field
|
28
|
+
|
29
|
+
-# = f.label :password
|
30
|
+
|
31
|
+
%br/
|
32
|
+
|
33
|
+
= f.password_field :password, autocomplete: "current-password",placeholder: "パスワード"
|
34
|
+
|
35
|
+
- if devise_mapping.rememberable?
|
36
|
+
|
37
|
+
.field
|
38
|
+
|
39
|
+
= f.check_box :remember_me
|
40
|
+
|
41
|
+
= f.label :remember_me
|
42
|
+
|
43
|
+
.actions
|
44
|
+
|
45
|
+
= f.submit "ログイン"
|
46
|
+
|
11
|
-
|
47
|
+
= render "devise/shared/links"
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```
|
12
52
|
|
13
53
|
新規登録時のview
|
14
54
|
|
55
|
+
```
|
56
|
+
|
57
|
+
.newreg
|
58
|
+
|
59
|
+
.newregstr
|
60
|
+
|
61
|
+
%h2.sign-up Kstagram
|
62
|
+
|
63
|
+
%h5 新しいアカウント作成
|
64
|
+
|
65
|
+
= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
|
66
|
+
|
67
|
+
= render "devise/shared/error_messages", resource: resource
|
68
|
+
|
69
|
+
.field
|
70
|
+
|
71
|
+
-# = f.label :email
|
72
|
+
|
73
|
+
%br/
|
74
|
+
|
75
|
+
= f.email_field :email, autofocus: true, autocomplete: "email",placeholder: "メールアドレス"
|
76
|
+
|
77
|
+
.field
|
78
|
+
|
79
|
+
-# = f.label :password
|
80
|
+
|
81
|
+
- if @minimum_password_length
|
82
|
+
|
83
|
+
%em
|
84
|
+
|
15
|
-
|
85
|
+
(#{@minimum_password_length} characters minimum)
|
86
|
+
|
87
|
+
%br/
|
88
|
+
|
89
|
+
= f.password_field :password, autocomplete: "new-password",placeholder: "パスワード"
|
90
|
+
|
91
|
+
.field
|
92
|
+
|
93
|
+
-# = f.label :password_confirmation
|
94
|
+
|
95
|
+
%br/
|
96
|
+
|
97
|
+
= f.password_field :password_confirmation, autocomplete: "new-password",placeholder: "パスワード確認"
|
98
|
+
|
99
|
+
.actions
|
100
|
+
|
101
|
+
= f.submit "Sign up"
|
102
|
+
|
103
|
+
= render "devise/shared/links"
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
```
|
16
108
|
|
17
109
|
マイグレーションファイル
|
18
110
|
|
111
|
+
```
|
112
|
+
|
113
|
+
# frozen_string_literal: true
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
class DeviseCreateUsers < ActiveRecord::Migration[5.2]
|
118
|
+
|
119
|
+
def change
|
120
|
+
|
121
|
+
create_table :users do |t|
|
122
|
+
|
123
|
+
## Database authenticatable
|
124
|
+
|
19
|
-
|
125
|
+
# t.string :username, null: false
|
126
|
+
|
20
|
-
|
127
|
+
t.string :email, null: false, default: ""
|
128
|
+
|
129
|
+
t.string :encrypted_password, null: false, default: ""
|
130
|
+
|
131
|
+
t.text :profile
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
## Recoverable
|
136
|
+
|
137
|
+
t.string :reset_password_token
|
138
|
+
|
139
|
+
t.datetime :reset_password_sent_at
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
## Rememberable
|
144
|
+
|
145
|
+
t.datetime :remember_created_at
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
## Trackable
|
150
|
+
|
21
|
-
|
151
|
+
# t.integer :sign_in_count, default: 0, null: false
|
152
|
+
|
153
|
+
# t.datetime :current_sign_in_at
|
154
|
+
|
155
|
+
# t.datetime :last_sign_in_at
|
156
|
+
|
157
|
+
# t.string :current_sign_in_ip
|
158
|
+
|
159
|
+
# t.string :last_sign_in_ip
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
## Confirmable
|
164
|
+
|
165
|
+
# t.string :confirmation_token
|
166
|
+
|
167
|
+
# t.datetime :confirmed_at
|
168
|
+
|
169
|
+
# t.datetime :confirmation_sent_at
|
170
|
+
|
171
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
## Lockable
|
176
|
+
|
177
|
+
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
178
|
+
|
179
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
180
|
+
|
181
|
+
# t.datetime :locked_at
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
t.timestamps null: false
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
# add_index :users, :username, unique: true
|
192
|
+
|
193
|
+
add_index :users, :email, unique: true
|
194
|
+
|
195
|
+
add_index :users, :reset_password_token, unique: true
|
196
|
+
|
197
|
+
# add_index :users, :confirmation_token, unique: true
|
198
|
+
|
199
|
+
# add_index :users, :unlock_token, unique: true
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
```
|
208
|
+
|
209
|
+
|
22
210
|
|
23
211
|
モデル
|
24
212
|
|
213
|
+
```
|
214
|
+
|
215
|
+
class User < ApplicationRecord
|
216
|
+
|
217
|
+
# Include default devise modules. Others available are:
|
218
|
+
|
219
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
220
|
+
|
25
|
-
|
221
|
+
devise :database_authenticatable, :registerable,
|
222
|
+
|
223
|
+
:recoverable, :rememberable, :validatable
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
# validates :username, presence: true #追記
|
228
|
+
|
229
|
+
# validates :profile, length: { maximum: 200 } #追記
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
```
|
4
マイグレーションファイル変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
マイグレーションファイル
|
18
18
|
|
19
|
-
![
|
19
|
+
![イメージ説明](25aa923e2ccc5cad280a9948ee50a725.png)
|
20
20
|
|
21
21
|
![イメージ説明](8e7d0debcfc56de4a7e7e709ce42d85d.png)
|
22
22
|
|
3
モデルとマイグレーションファイル追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,3 +13,13 @@
|
|
13
13
|
新規登録時のview
|
14
14
|
|
15
15
|
![イメージ説明](db0a26e103a81ca173779c0a6c27107d.png)
|
16
|
+
|
17
|
+
マイグレーションファイル
|
18
|
+
|
19
|
+
![![イメージ説明](9c83db4c723b9e4744b053e5a7856cdb.png)]
|
20
|
+
|
21
|
+
![イメージ説明](8e7d0debcfc56de4a7e7e709ce42d85d.png)
|
22
|
+
|
23
|
+
モデル
|
24
|
+
|
25
|
+
![イメージ説明](3466bca00877615c572f46224f56478d.png)
|
2
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ActiveRecord::NotNullViolation in Devise::RegistrationsController#create
|
test
CHANGED
File without changes
|
1
新規登録、ログイン時のviewを追加しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ActiveRecord::NotNullViolation in Devise::RegistrationsController#create
|
1
|
+
しActiveRecord::NotNullViolation in Devise::RegistrationsController#create
|
test
CHANGED
@@ -5,3 +5,11 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
![イメージ説明](58cc696a1261388608ec8e057a7d4a14.png)
|
8
|
+
|
9
|
+
ログイン時のview
|
10
|
+
|
11
|
+
![イメージ説明](cdd8c3c9672d8b532e8499ca86c195b5.png)
|
12
|
+
|
13
|
+
新規登録時のview
|
14
|
+
|
15
|
+
![イメージ説明](db0a26e103a81ca173779c0a6c27107d.png)
|