質問編集履歴
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -207,3 +207,9 @@
|
|
207
207
|
has_many :group_posts, dependent: :delete_all
|
208
208
|
|
209
209
|
```
|
210
|
+
|
211
|
+
###追記3
|
212
|
+
|
213
|
+
現在のエラー
|
214
|
+
|
215
|
+
![イメージ説明](268dcf882e93dd52ce411252a08df1e5.png)
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -168,4 +168,42 @@
|
|
168
168
|
|
169
169
|
end
|
170
170
|
|
171
|
+
create_table "posts", force: :cascade do |t|
|
172
|
+
|
173
|
+
t.text "content"
|
174
|
+
|
175
|
+
t.datetime "created_at", null: false
|
176
|
+
|
177
|
+
t.datetime "updated_at", null: false
|
178
|
+
|
179
|
+
t.integer "user_id"
|
180
|
+
|
181
|
+
t.string "image_name"
|
182
|
+
|
183
|
+
t.string "title"
|
184
|
+
|
185
|
+
end
|
186
|
+
|
171
|
-
```
|
187
|
+
```
|
188
|
+
|
189
|
+
```Model
|
190
|
+
|
191
|
+
class User < ApplicationRecord
|
192
|
+
|
193
|
+
has_many :posts, dependent: :delete_all
|
194
|
+
|
195
|
+
has_many :group_users
|
196
|
+
|
197
|
+
has_many :groups, through: :group_users
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
```Model
|
202
|
+
|
203
|
+
class Post < ApplicationRecord
|
204
|
+
|
205
|
+
belongs_to :user
|
206
|
+
|
207
|
+
has_many :group_posts, dependent: :delete_all
|
208
|
+
|
209
|
+
```
|
2
追記2
test
CHANGED
File without changes
|
test
CHANGED
@@ -115,3 +115,57 @@
|
|
115
115
|
group_post_ids に変更した場合エラーは無くなりますが、if分の条件に該当せず閲覧出来ません。
|
116
116
|
|
117
117
|
![イメージ説明](9ed968e9fb4ccfff229ccd291f750792.png)
|
118
|
+
|
119
|
+
###追記2
|
120
|
+
|
121
|
+
```schema
|
122
|
+
|
123
|
+
create_table "group_posts", force: :cascade do |t|
|
124
|
+
|
125
|
+
t.integer "group_id"
|
126
|
+
|
127
|
+
t.integer "post_id"
|
128
|
+
|
129
|
+
t.datetime "created_at", null: false
|
130
|
+
|
131
|
+
t.datetime "updated_at", null: false
|
132
|
+
|
133
|
+
t.index ["group_id"], name: "index_group_posts_on_group_id"
|
134
|
+
|
135
|
+
t.index ["post_id"], name: "index_group_posts_on_post_id"
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
create_table "group_users", force: :cascade do |t|
|
142
|
+
|
143
|
+
t.integer "group_id"
|
144
|
+
|
145
|
+
t.integer "user_id"
|
146
|
+
|
147
|
+
t.datetime "created_at", null: false
|
148
|
+
|
149
|
+
t.datetime "updated_at", null: false
|
150
|
+
|
151
|
+
t.index ["group_id"], name: "index_group_users_on_group_id"
|
152
|
+
|
153
|
+
t.index ["user_id"], name: "index_group_users_on_user_id"
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
create_table "groups", force: :cascade do |t|
|
160
|
+
|
161
|
+
t.string "name"
|
162
|
+
|
163
|
+
t.text "content"
|
164
|
+
|
165
|
+
t.datetime "created_at", null: false
|
166
|
+
|
167
|
+
t.datetime "updated_at", null: false
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -103,3 +103,15 @@
|
|
103
103
|
現在、答えにたどり着けずにいます。
|
104
104
|
|
105
105
|
お分かりの方、ぜひ宜しくお願いします。
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
###追記
|
110
|
+
|
111
|
+
現在のエラーです。
|
112
|
+
|
113
|
+
![イメージ説明](bbd313887091e7f219df9d159e29f7cf.png)
|
114
|
+
|
115
|
+
group_post_ids に変更した場合エラーは無くなりますが、if分の条件に該当せず閲覧出来ません。
|
116
|
+
|
117
|
+
![イメージ説明](9ed968e9fb4ccfff229ccd291f750792.png)
|