teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

修正

2020/07/13 03:47

投稿

atage517
atage517

スコア36

title CHANGED
File without changes
body CHANGED
@@ -97,6 +97,18 @@
97
97
  end
98
98
  end
99
99
  ```
100
+ ```ここに言語を入力
101
+ class CreatePosts < ActiveRecord::Migration[6.0]
102
+ def change
103
+ create_table :posts do |t|
104
+ t.text :title
105
+ t.text :content
106
+ t.integer :user_id
100
107
 
108
+ t.timestamps
109
+ end
110
+ end
111
+ end
112
+ ```
101
- 上記はUserのmigrationファイルのなかみです
113
+ 上記はUserとPostのmigrationファイルのなかみです
102
114
  どのようにしたらpostをuserモデルの関係性を示し、自分をおなじ学部(subject)のユーザーの投稿のみを表示できるようになるでしょうか?