質問編集履歴

1

モデルファイルの追加

2018/11/23 01:42

投稿

daigakuse-
daigakuse-

スコア67

test CHANGED
File without changes
test CHANGED
@@ -119,3 +119,49 @@
119
119
  end
120
120
 
121
121
  ```
122
+
123
+
124
+
125
+ モデルファイルは以下の通りです。
126
+
127
+ ```
128
+
129
+ class RoomGroup < ApplicationRecord
130
+
131
+ belongs_to :user
132
+
133
+ belongs_to :room
134
+
135
+ end
136
+
137
+ ```
138
+
139
+
140
+
141
+ ```
142
+
143
+ class Room < ApplicationRecord
144
+
145
+ has_many :room_groups
146
+
147
+ has_many :users ,through: :room_groups
148
+
149
+ end
150
+
151
+ ```
152
+
153
+
154
+
155
+ ```
156
+
157
+ class User < ApplicationRecord
158
+
159
+ has_many :room_groups
160
+
161
+ has_many :rooms ,through: :room_groups
162
+
163
+ end
164
+
165
+
166
+
167
+ ```