質問編集履歴

1

モデルのコードを追加

2020/02/08 13:26

投稿

kawayannn
kawayannn

スコア5

test CHANGED
File without changes
test CHANGED
@@ -102,6 +102,72 @@
102
102
 
103
103
  ```
104
104
 
105
+ user.rb
106
+
107
+ ```
108
+
109
+ has_many :articles, dependent: :destroy
110
+
111
+ has_many :comments, dependent: :destroy
112
+
113
+ has_many :messages, dependent: :destroy
114
+
115
+ #中略
116
+
117
+ has_many :group_users, dependent: :destroy
118
+
119
+ has_many :groups, through: :group_users
120
+
121
+ ```
122
+
123
+ article.rb
124
+
125
+ ```
126
+
127
+ belongs_to :user
128
+
129
+ has_many :comments, dependent: :destroy
130
+
131
+ ```
132
+
133
+
134
+
135
+ comment.rb
136
+
137
+ ```
138
+
139
+ belongs_to :user
140
+
141
+ belongs_to :article
142
+
143
+ ```
144
+
145
+ group.rb
146
+
147
+ ```
148
+
149
+ has_many :group_users, dependent: :destroy
150
+
151
+ has_many :users, through: :group_users
152
+
153
+
154
+
155
+ has_many :messages
156
+
157
+ ```
158
+
159
+ message.rb
160
+
161
+ ```
162
+
163
+ belongs_to :group
164
+
165
+ belongs_to :user
166
+
167
+ ```
168
+
169
+
170
+
105
171
 
106
172
 
107
173
  ### 試したこと