質問編集履歴
4
もうひとつの改善策を記述しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -487,3 +487,11 @@
|
|
487
487
|
の記述を加えてみたのですがだめでした。
|
488
488
|
|
489
489
|
そして、userに関するテーブル(以下、userテーブル)の情報を外部キーで参照させてみたのですがだめでした。
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
もう一つ試してみたこととしては、
|
494
|
+
|
495
|
+
`@blog = current_user.blog_build(blog_params)`を`blog_params`に入れてみたのですが、SystemStackErrorになってしまいました。
|
496
|
+
|
497
|
+
その後にcreateメソッドの一番上に書いたノオですが、だめでした。
|
3
エラーログを載せました
test
CHANGED
File without changes
|
test
CHANGED
@@ -386,6 +386,74 @@
|
|
386
386
|
|
387
387
|
```
|
388
388
|
|
389
|
+
|
390
|
+
|
391
|
+
##エラーログ
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
```
|
396
|
+
|
397
|
+
[ActiveJob] [ActiveStorage::AnalyzeJob] [a108ccf5-a6f4-4942-a82d-c92d6232d759] (0.5ms) BEGIN
|
398
|
+
|
399
|
+
web_1 | [ActiveJob] [ActiveStorage::AnalyzeJob] [a108ccf5-a6f4-4942-a82d-c92d6232d759] ActiveStorage::Blob Update (0.8ms) UPDATE `active_storage_blobs` SET `active_storage_blobs`.`metadata` = '{\"identified\":true,\"width\":3000,\"height\":4000,\"analyzed\":true}' WHERE `active_storage_blobs`.`id` = 1
|
400
|
+
|
401
|
+
web_1 | [ActiveJob] [ActiveStorage::AnalyzeJob] [a108ccf5-a6f4-4942-a82d-c92d6232d759] (1.9ms) COMMIT
|
402
|
+
|
403
|
+
web_1 | [ActiveJob] [ActiveStorage::AnalyzeJob] [a108ccf5-a6f4-4942-a82d-c92d6232d759] Performed ActiveStorage::AnalyzeJob (Job ID: a108ccf5-a6f4-4942-a82d-c92d6232d759) from Async(active_storage_analysis) in 490.41ms
|
404
|
+
|
405
|
+
web_1 | Started POST "/blogs" for 172.20.0.1 at 2021-04-09 13:57:09 +0000
|
406
|
+
|
407
|
+
web_1 | Cannot render console from 172.20.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
|
408
|
+
|
409
|
+
web_1 | Processing by BlogsController#create as HTML
|
410
|
+
|
411
|
+
web_1 | Parameters: {"authenticity_token"=>"PgGSiA8pdNxDZLah7O6+zovBN8WqROOpLkBdICHAflLTRUkLyVteKvkQqNXdCRXdwSjbsjzPZUTnHFmwOwKY/A==", "blog"=>{"body"=>"<div>asdfasddfasdfd</div>"}, "commit"=>"投稿する"}
|
412
|
+
|
413
|
+
web_1 | User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
|
414
|
+
|
415
|
+
web_1 | (1.0ms) BEGIN
|
416
|
+
|
417
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:30:in `block in create'
|
418
|
+
|
419
|
+
web_1 | User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
|
420
|
+
|
421
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:30:in `block in create'
|
422
|
+
|
423
|
+
web_1 | Blog Create (0.9ms) INSERT INTO `blogs` (`user_id`, `created_at`, `updated_at`) VALUES (1, '2021-04-09 13:57:09.087366', '2021-04-09 13:57:09.087366')
|
424
|
+
|
425
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:30:in `block in create'
|
426
|
+
|
427
|
+
web_1 | ActionText::RichText Create (1.2ms) INSERT INTO `action_text_rich_texts` (`name`, `body`, `record_type`, `record_id`, `created_at`, `updated_at`) VALUES ('body', '<div>asdfasddfasdfd</div>', 'Blog', 1, '2021-04-09 13:57:09.094594', '2021-04-09 13:57:09.094594')
|
428
|
+
|
429
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:30:in `block in create'
|
430
|
+
|
431
|
+
web_1 | (3.1ms) ROLLBACK
|
432
|
+
|
433
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:30:in `block in create'
|
434
|
+
|
435
|
+
web_1 | Rendered /usr/local/bundle/gems/actiontext-6.0.3.6/app/views/action_text/content/_layout.html.erb (Duration: 0.9ms | Allocations: 211)
|
436
|
+
|
437
|
+
web_1 | Rendered /usr/local/bundle/gems/actiontext-6.0.3.6/app/views/action_text/content/_layout.html.erb (Duration: 0.9ms | Allocations: 202)
|
438
|
+
|
439
|
+
web_1 | Completed 500 Internal Server Error in 50ms (ActiveRecord: 7.5ms | Allocations: 10608)
|
440
|
+
|
441
|
+
web_1 |
|
442
|
+
|
443
|
+
web_1 |
|
444
|
+
|
445
|
+
web_1 |
|
446
|
+
|
447
|
+
web_1 | ActiveRecord::NotNullViolation (Mysql2::Error: Field 'user_id' doesn't have a default value):
|
448
|
+
|
449
|
+
web_1 |
|
450
|
+
|
451
|
+
web_1 | app/controllers/blogs_controller.rb:30:in `block in create'
|
452
|
+
|
453
|
+
web_1 | app/controllers/blogs_controller.rb:29:in `create'
|
454
|
+
|
455
|
+
```
|
456
|
+
|
389
457
|
##やってみたこと
|
390
458
|
|
391
459
|
|
2
エラーログなどの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -326,6 +326,66 @@
|
|
326
326
|
|
327
327
|
|
328
328
|
|
329
|
+
##エラーログ
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
```
|
334
|
+
|
335
|
+
app/controllers/blogs_controller.rb:25:in `create'
|
336
|
+
|
337
|
+
web_1 | Started POST "/blogs" for 172.21.0.1 at 2021-04-09 04:07:34 +0000
|
338
|
+
|
339
|
+
web_1 | Cannot render console from 172.21.0.1! Allowed networks: 127.0.0.0/127.255.255.255, ::1
|
340
|
+
|
341
|
+
web_1 | (0.4ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
|
342
|
+
|
343
|
+
web_1 | Processing by BlogsController#create as HTML
|
344
|
+
|
345
|
+
web_1 | Parameters: {"authenticity_token"=>"bfwO2lxDbUi582//E7VFCXRmV7KP7HLmOg8btH68D3QVkRsimz2uRHei3Eg1BrRD7MfbX/+PEeliiRfg5C1/ag==", "blog"=>{"body"=>"<div>asdfasdfasdf</div>"}, "commit"=>"投稿する"}
|
346
|
+
|
347
|
+
web_1 | User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
|
348
|
+
|
349
|
+
web_1 | (0.4ms) BEGIN
|
350
|
+
|
351
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:28:in `block in create'
|
352
|
+
|
353
|
+
web_1 | User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
|
354
|
+
|
355
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:28:in `block in create'
|
356
|
+
|
357
|
+
web_1 | Blog Create (0.8ms) INSERT INTO `blogs` (`user_id`, `created_at`, `updated_at`) VALUES (1, '2021-04-09 04:07:34.485874', '2021-04-09 04:07:34.485874')
|
358
|
+
|
359
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:28:in `block in create'
|
360
|
+
|
361
|
+
web_1 | ActionText::RichText Create (1.1ms) INSERT INTO `action_text_rich_texts` (`name`, `body`, `record_type`, `record_id`, `created_at`, `updated_at`) VALUES ('body', '<div>asdfasdfasdf</div>', 'Blog', 1, '2021-04-09 04:07:34.706717', '2021-04-09 04:07:34.706717')
|
362
|
+
|
363
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:28:in `block in create'
|
364
|
+
|
365
|
+
web_1 | (1.7ms) ROLLBACK
|
366
|
+
|
367
|
+
web_1 | ↳ app/controllers/blogs_controller.rb:28:in `block in create'
|
368
|
+
|
369
|
+
web_1 | Rendered /usr/local/bundle/gems/actiontext-6.0.3.6/app/views/action_text/content/_layout.html.erb (Duration: 1.8ms | Allocations: 314)
|
370
|
+
|
371
|
+
web_1 | Rendered /usr/local/bundle/gems/actiontext-6.0.3.6/app/views/action_text/content/_layout.html.erb (Duration: 0.7ms | Allocations: 199)
|
372
|
+
|
373
|
+
web_1 | Completed 500 Internal Server Error in 323ms (ActiveRecord: 6.5ms | Allocations: 37537)
|
374
|
+
|
375
|
+
```
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
##エラー画面のパラメーター
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
```
|
384
|
+
|
385
|
+
{"authenticity_token"=>"bfwO2lxDbUi582//E7VFCXRmV7KP7HLmOg8btH68D3QVkRsimz2uRHei3Eg1BrRD7MfbX/+PEeliiRfg5C1/ag==", "blog"=>{"body"=>"<div>asdfasdfasdf</div>"}, "commit"=>"投稿する"}
|
386
|
+
|
387
|
+
```
|
388
|
+
|
329
389
|
##やってみたこと
|
330
390
|
|
331
391
|
|
1
やってみたことについての追記とエラーメッセージの内容が変わったのでそこの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
1 error prohibited this blog from being saved:
|
8
8
|
|
9
|
-
User
|
9
|
+
Userを入力してください
|
10
10
|
|
11
11
|
```
|
12
12
|
|
@@ -194,6 +194,78 @@
|
|
194
194
|
|
195
195
|
|
196
196
|
|
197
|
+
action_textに関するマイグレーションファイル
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
# This migration comes from action_text (originally 20180528164100)
|
202
|
+
|
203
|
+
class CreateActionTextTables < ActiveRecord::Migration[6.0]
|
204
|
+
|
205
|
+
def change
|
206
|
+
|
207
|
+
create_table :action_text_rich_texts do |t|
|
208
|
+
|
209
|
+
t.string :name, null: false
|
210
|
+
|
211
|
+
t.string :title, null: false
|
212
|
+
|
213
|
+
t.text :body, size: :long
|
214
|
+
|
215
|
+
t.references :record, null: false, polymorphic: true, index: false
|
216
|
+
|
217
|
+
t.references :user, foreign_key: true, null: false
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
t.timestamps
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
```
|
236
|
+
|
237
|
+
ブログに関するマイグレーションファイル
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
```
|
242
|
+
|
243
|
+
class CreateBlogs < ActiveRecord::Migration[6.0]
|
244
|
+
|
245
|
+
def change
|
246
|
+
|
247
|
+
create_table :blogs do |t|
|
248
|
+
|
249
|
+
t.string :title
|
250
|
+
|
251
|
+
t.string :body
|
252
|
+
|
253
|
+
t.references :user, foreign_key: true, null: false
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
t.timestamps
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
|
265
|
+
```
|
266
|
+
|
267
|
+
|
268
|
+
|
197
269
|
ブログ投稿フォーム
|
198
270
|
|
199
271
|
```
|
@@ -285,3 +357,5 @@
|
|
285
357
|
```
|
286
358
|
|
287
359
|
の記述を加えてみたのですがだめでした。
|
360
|
+
|
361
|
+
そして、userに関するテーブル(以下、userテーブル)の情報を外部キーで参照させてみたのですがだめでした。
|