質問編集履歴

2

ll

2020/09/23 09:33

投稿

Meitoku
Meitoku

スコア44

test CHANGED
File without changes
test CHANGED
@@ -92,11 +92,15 @@
92
92
 
93
93
  class Category < ApplicationRecord
94
94
 
95
- has_many :category_tweets
95
+ //has_many :category_tweets
96
96
 
97
97
  has_many :tweets,through: :category_tweets
98
98
 
99
99
  has_ancestry
100
+
101
+ has_many :school_a_category_tweets, foreign_key: 'school_a_id'
102
+
103
+ has_many :school_b_category_tweets, foreign_key: 'school_b_id'
100
104
 
101
105
  end
102
106
 
@@ -114,7 +118,11 @@
114
118
 
115
119
  belongs_to :tweet
116
120
 
117
- belongs_to :category
121
+ //belongs_to :category
122
+
123
+ belongs_to :school_a, foreign_key: 'school_a_id'
124
+
125
+ belongs_to :school_b, foreign_key: 'school_b_id'
118
126
 
119
127
  end
120
128
 

1

変更

2020/09/23 09:33

投稿

Meitoku
Meitoku

スコア44

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  参考にした記事
12
12
 
13
- https://blog.yayawatanabe.net/entry/2018/12/17/222107
13
+ [中間テーブル](https://blog.yayawatanabe.net/entry/2018/12/17/222107)
14
14
 
15
15
 
16
16