質問編集履歴
3
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -255,3 +255,95 @@
|
|
255
255
|
|
256
256
|
|
257
257
|
も入れた方がよろしいでしょうか?
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
追加
|
264
|
+
|
265
|
+
rails migrateを行なった時に
|
266
|
+
|
267
|
+
以下のようになります。
|
268
|
+
|
269
|
+
```rails
|
270
|
+
|
271
|
+
ActiveRecord::Schema.define(version: 2020_07_30_062001) do
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
create_table "comments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
276
|
+
|
277
|
+
t.integer "user_id"
|
278
|
+
|
279
|
+
t.integer "tweet_id"
|
280
|
+
|
281
|
+
t.text "text"
|
282
|
+
|
283
|
+
t.datetime "created_at", precision: 6, null: false
|
284
|
+
|
285
|
+
t.datetime "updated_at", precision: 6, null: false
|
286
|
+
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
create_table "favorites", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
292
|
+
|
293
|
+
t.datetime "created_at", precision: 6, null: false
|
294
|
+
|
295
|
+
t.datetime "updated_at", precision: 6, null: false
|
296
|
+
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
create_table "tweets", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
302
|
+
|
303
|
+
t.string "title"
|
304
|
+
|
305
|
+
t.string "text"
|
306
|
+
|
307
|
+
t.string "image"
|
308
|
+
|
309
|
+
t.datetime "created_at", precision: 6, null: false
|
310
|
+
|
311
|
+
t.datetime "updated_at", precision: 6, null: false
|
312
|
+
|
313
|
+
t.integer "user_id"
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
320
|
+
|
321
|
+
t.string "email", default: "", null: false
|
322
|
+
|
323
|
+
t.string "encrypted_password", default: "", null: false
|
324
|
+
|
325
|
+
t.string "reset_password_token"
|
326
|
+
|
327
|
+
t.datetime "reset_password_sent_at"
|
328
|
+
|
329
|
+
t.datetime "remember_created_at"
|
330
|
+
|
331
|
+
t.datetime "created_at", precision: 6, null: false
|
332
|
+
|
333
|
+
t.datetime "updated_at", precision: 6, null: false
|
334
|
+
|
335
|
+
t.string "nickname"
|
336
|
+
|
337
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
338
|
+
|
339
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
340
|
+
|
341
|
+
end
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
```
|
2
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -173,3 +173,85 @@
|
|
173
173
|
|
174
174
|
|
175
175
|
```
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
favoriteモデル
|
180
|
+
|
181
|
+
```rails
|
182
|
+
|
183
|
+
class Favorite < ApplicationRecord
|
184
|
+
|
185
|
+
belongs_to :user
|
186
|
+
|
187
|
+
belongs_to :tweet
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
```
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
こちらになります。
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
関連した記事のスキーマーの記載の箇所に
|
202
|
+
|
203
|
+
```rails
|
204
|
+
|
205
|
+
schema.rb
|
206
|
+
|
207
|
+
create_table "users", force: :cascade do |t|
|
208
|
+
|
209
|
+
(略)
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
create_table "products", force: :cascade do |t|
|
214
|
+
|
215
|
+
(略)
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
create_table "favorites", force: :cascade do |t|
|
222
|
+
|
223
|
+
t.integer "user_id", null: false
|
224
|
+
|
225
|
+
t.integer "product_id", null: false
|
226
|
+
|
227
|
+
t.datetime "created_at", null: false
|
228
|
+
|
229
|
+
t.datetime "updated_at", null: false
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
```
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
とありますがもしかしたら
|
238
|
+
|
239
|
+
```rails
|
240
|
+
|
241
|
+
create_table "users", force: :cascade do |t|
|
242
|
+
|
243
|
+
(略)
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
create_table "products", force: :cascade do |t|
|
248
|
+
|
249
|
+
(略)
|
250
|
+
|
251
|
+
end
|
252
|
+
|
253
|
+
```
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
も入れた方がよろしいでしょうか?
|
1
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -79,3 +79,97 @@
|
|
79
79
|
ご教授願えたら幸いです。
|
80
80
|
|
81
81
|
よろしくお願いします。
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
追加
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
スキーマー
|
90
|
+
|
91
|
+
```rails
|
92
|
+
|
93
|
+
ctiveRecord::Schema.define(version: 2020_07_14_100939) do
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
create_table "comments", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
98
|
+
|
99
|
+
t.integer "user_id"
|
100
|
+
|
101
|
+
t.integer "tweet_id"
|
102
|
+
|
103
|
+
t.text "text"
|
104
|
+
|
105
|
+
t.datetime "created_at", precision: 6, null: false
|
106
|
+
|
107
|
+
t.datetime "updated_at", precision: 6, null: false
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
create_table "tweets", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
114
|
+
|
115
|
+
t.string "title"
|
116
|
+
|
117
|
+
t.string "text"
|
118
|
+
|
119
|
+
t.string "image"
|
120
|
+
|
121
|
+
t.datetime "created_at", precision: 6, null: false
|
122
|
+
|
123
|
+
t.datetime "updated_at", precision: 6, null: false
|
124
|
+
|
125
|
+
t.integer "user_id"
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
132
|
+
|
133
|
+
t.string "email", default: "", null: false
|
134
|
+
|
135
|
+
t.string "encrypted_password", default: "", null: false
|
136
|
+
|
137
|
+
t.string "reset_password_token"
|
138
|
+
|
139
|
+
t.datetime "reset_password_sent_at"
|
140
|
+
|
141
|
+
t.datetime "remember_created_at"
|
142
|
+
|
143
|
+
t.datetime "created_at", precision: 6, null: false
|
144
|
+
|
145
|
+
t.datetime "updated_at", precision: 6, null: false
|
146
|
+
|
147
|
+
t.string "nickname"
|
148
|
+
|
149
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
150
|
+
|
151
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
create_table "favorites", force: :cascade do |t|
|
158
|
+
|
159
|
+
t.integer "user_id", null: false
|
160
|
+
|
161
|
+
t.integer "tweet_id", null: false
|
162
|
+
|
163
|
+
t.datetime "created_at", null: false
|
164
|
+
|
165
|
+
t.datetime "updated_at", null: false
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
```
|