質問編集履歴

2

コードの更新

2021/02/27 06:25

投稿

yukitodesu3
yukitodesu3

スコア10

test CHANGED
File without changes
test CHANGED
@@ -322,6 +322,40 @@
322
322
 
323
323
 
324
324
 
325
+ user.rb
326
+
327
+ ```
328
+
329
+ class User < ApplicationRecord
330
+
331
+ # Include default devise modules. Others available are:
332
+
333
+ # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
334
+
335
+ devise :database_authenticatable, :registerable,
336
+
337
+ :recoverable, :rememberable, :validatable
338
+
339
+
340
+
341
+ has_many :books, dependent: :destroy
342
+
343
+ attachment :profile_image
344
+
345
+
346
+
347
+ validates :name, uniqueness:true, presence: true, length: { minimum: 2, maximum: 20 }
348
+
349
+ validates :introduction, length: {maximum: 50 }
350
+
351
+
352
+
353
+ end
354
+
355
+ ```
356
+
357
+
358
+
325
359
  試したこと
326
360
 
327
361
  ・エラー内容の確認

1

コードの編集

2021/02/27 06:25

投稿

yukitodesu3
yukitodesu3

スコア10

test CHANGED
File without changes
test CHANGED
@@ -292,6 +292,36 @@
292
292
 
293
293
 
294
294
 
295
+
296
+
297
+ book.rb
298
+
299
+ ```
300
+
301
+ class Book < ApplicationRecord
302
+
303
+ belongs_to :user
304
+
305
+ attachment :image
306
+
307
+ has_many :post_comments
308
+
309
+
310
+
311
+ validates :title, presence: true
312
+
313
+ validates :body, presence: true, length: { maximum: 200 }
314
+
315
+
316
+
317
+ end
318
+
319
+
320
+
321
+ ```
322
+
323
+
324
+
295
325
  試したこと
296
326
 
297
327
  ・エラー内容の確認