質問編集履歴
1
アソシエーションの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -153,3 +153,55 @@
|
|
153
153
|
初めてアプリケーションを一から作成しています。
|
154
154
|
|
155
155
|
お見苦しいところは多々あると思いますが、どうかご指導ください。
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
追記ーーーー
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
アソシエーション
|
164
|
+
|
165
|
+
```user
|
166
|
+
|
167
|
+
devise :database_authenticatable, :registerable,
|
168
|
+
|
169
|
+
:recoverable, :rememberable, :validatable
|
170
|
+
|
171
|
+
has_many :contents, through: :comments
|
172
|
+
|
173
|
+
has_many :categories, through: :contents
|
174
|
+
|
175
|
+
has_many :comments
|
176
|
+
|
177
|
+
```
|
178
|
+
|
179
|
+
```category
|
180
|
+
|
181
|
+
belongs_to :user
|
182
|
+
|
183
|
+
has_many :contents
|
184
|
+
|
185
|
+
has_many :users, through: :contents
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
```content
|
190
|
+
|
191
|
+
belongs_to :user
|
192
|
+
|
193
|
+
belongs_to :category
|
194
|
+
|
195
|
+
has_many :user, through: :comments
|
196
|
+
|
197
|
+
```
|
198
|
+
|
199
|
+
```comment
|
200
|
+
|
201
|
+
belongs_to :user
|
202
|
+
|
203
|
+
belongs_to :content
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
となっています
|