質問編集履歴

1

models/user.rbを追加しました。

2018/08/23 10:03

投稿

akiakiakirin
akiakiakirin

スコア13

test CHANGED
File without changes
test CHANGED
@@ -487,3 +487,39 @@
487
487
 
488
488
 
489
489
  ```
490
+
491
+ ### models/user.rb
492
+
493
+ ```
494
+
495
+ class User < ApplicationRecord
496
+
497
+ # Include default devise modules. Others available are:
498
+
499
+ # :confirmable, :lockable, :timeoutable and :omniauthable
500
+
501
+ devise :database_authenticatable, :registerable,
502
+
503
+ :recoverable, :rememberable, :trackable, :validatable
504
+
505
+
506
+
507
+ has_many :posts
508
+
509
+
510
+
511
+ def posts
512
+
513
+ return Post.where(user_id: self.id)
514
+
515
+ end
516
+
517
+
518
+
519
+
520
+
521
+ end
522
+
523
+
524
+
525
+ ```