質問編集履歴
2
user.rbの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -291,3 +291,67 @@
|
|
291
291
|
</div>
|
292
292
|
|
293
293
|
```
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
--------追記--------
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
```userrb
|
302
|
+
|
303
|
+
class User < ApplicationRecord
|
304
|
+
|
305
|
+
# Include default devise modules. Others available are:
|
306
|
+
|
307
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
308
|
+
|
309
|
+
devise :database_authenticatable, :registerable,
|
310
|
+
|
311
|
+
:recoverable, :rememberable, :validatable
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
extend ActiveHash::Associations::ActiveRecordExtensions
|
316
|
+
|
317
|
+
belongs_to_active_hash :gender
|
318
|
+
|
319
|
+
has_many :posts, dependent: :destroy
|
320
|
+
|
321
|
+
has_many :comments, dependent: :destroy
|
322
|
+
|
323
|
+
has_many :favorites, dependent: :destroy
|
324
|
+
|
325
|
+
has_many :favorite_posts, through: :favorites, source: :post
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
with_options presence: true do
|
330
|
+
|
331
|
+
validates :nickname
|
332
|
+
|
333
|
+
validates :gender_id
|
334
|
+
|
335
|
+
end
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
validates :email, uniqueness: true
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
validates :nickname, length: { maximum: 8, message: "は8文字以下にしてください" }
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
validates :gender_id, numericality: { other_than: 1, message: "を選択してください" }
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
half_width_alphanumeric = /\A(?=.*?[a-z])(?=.*?\d)[a-z\d]{6,100}+\z/i
|
352
|
+
|
353
|
+
validates :password, presence: true, format: { with: half_width_alphanumeric, message: "に半角英数字を使用してください" }
|
354
|
+
|
355
|
+
end
|
356
|
+
|
357
|
+
```
|
1
タイトルをわかりやすく変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
deviseを使ったユーザー編集機能が実装できない
|
1
|
+
deviseを使ったパスワードなしユーザー編集機能が実装できない
|
test
CHANGED
File without changes
|