質問編集履歴

2

畏まりました!

2017/12/14 17:23

投稿

Syota
Syota

スコア28

test CHANGED
File without changes
test CHANGED
File without changes

1

畏まりました!

2017/12/14 17:23

投稿

Syota
Syota

スコア28

test CHANGED
File without changes
test CHANGED
@@ -305,3 +305,43 @@
305
305
  コード
306
306
 
307
307
  ```
308
+
309
+
310
+
311
+ commentモデル
312
+
313
+ ```
314
+
315
+ class Coment < ApplicationRecord
316
+
317
+ belongs_to :post
318
+
319
+ validates :body, presence: true
320
+
321
+ end
322
+
323
+ コード
324
+
325
+ ```
326
+
327
+
328
+
329
+ postモデル
330
+
331
+ ```
332
+
333
+ class Post < ApplicationRecord
334
+
335
+ has_many :comments
336
+
337
+ # @post.coments
338
+
339
+ #validates :title, presence: true, length:{ minimum: 3, message: 'タイトルを入力して下さい'}
340
+
341
+ validates :body, presence: true
342
+
343
+ end
344
+
345
+ コード
346
+
347
+ ```