質問編集履歴

1

パラメーターの送信状況をコードに変更しました。

2020/11/06 01:35

投稿

yyu202
yyu202

スコア2

test CHANGED
File without changes
test CHANGED
@@ -322,9 +322,175 @@
322
322
 
323
323
  パラメーターは送信できるのですが、一括保存をしたいMaterialテーブルにだけ保存ができません。
324
324
 
325
- [paramsの送信状況](https://i.gyazo.com/e63095d83252cdfba1433e62d6194bcf.png)
326
-
327
- [paramsの送信状況2](https://i.gyazo.com/2155800557845bd20750b15273540ca1.png)
325
+ ↓パラメーターの送信状況です。
326
+
327
+ ```
328
+
329
+ 10: def create
330
+
331
+ 11: @cook_recipe = Form::CookRecipe.new(recipe_params)
332
+
333
+ 12: url = params[:form_cook_recipe][:video]
334
+
335
+ 13: url = url.last(11)
336
+
337
+ 14: @cook_recipe.video = url
338
+
339
+ => 15: binding.pry
340
+
341
+ 16:
342
+
343
+ 17: if @cook_recipe.save
344
+
345
+ 18: redirect_to root_path
346
+
347
+ 19: else
348
+
349
+ 20: render :new
350
+
351
+ 21: end
352
+
353
+ 22: end
354
+
355
+
356
+
357
+ [1] pry(#<RecipesController>)> params
358
+
359
+ => <ActionController::Parameters {"authenticity_token"=>"m9wXOBjyMuu/aZOcthfY2WhpF8dy/Xsc1pQkKj9MTP7Ufty6K3npGknmuBpErMD7Upd+Mr35cR7fR2imElB61A==", "form_cook_recipe"=><ActionController::Parameters {"title"=>"pooppopopo", "text"=>"tatatatatatatattata", "cooks_attributes"=>{"0"=>{"vegetable_1"=>"ko"}, "1"=>{"vegetable_1"=>"mu"}, "2"=>{"vegetable_1"=>"gi"}}, "cook_1"=>"eeeeee", "image"=>#<ActionDispatch::Http::UploadedFile:0x00007feb02897d90 @tempfile=#<Tempfile:/var/folders/vq/prgw2yxj1ns327cvwpw4plrc0000gn/T/RackMultipart20201105-1740-xxn2lg.jpg>, @original_filename="7ac726af05cc3a5a5cdea8819379ede6.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"form_cook_recipe[image]\"; filename=\"7ac726af05cc3a5a5cdea8819379ede6.jpg\"\r\nContent-Type: image/jpeg\r\n">, "video"=>"VgmYtFxp-SY"} permitted: false>, "commit"=>"投稿", "controller"=>"recipes", "action"=>"create"} permitted: false>
360
+
361
+ [2] pry(#<RecipesController>)> @cook_recipe
362
+
363
+ => #<Form::CookRecipe:0x00007feaffbeeb40
364
+
365
+ @attributes=#<ActiveModel::AttributeSet:0x00007feaffbeea28 @attributes={}>,
366
+
367
+ @cook_1="eeeeee",
368
+
369
+ @cooks=
370
+
371
+ [#<Material:0x00007feaffc06790
372
+
373
+ id: nil,
374
+
375
+ vegetable_1: "ko",
376
+
377
+ vegetable_2: nil,
378
+
379
+ vegetable_3: nil,
380
+
381
+ vegetable_4: nil,
382
+
383
+ vegetable_5: nil,
384
+
385
+ vegetable_6: nil,
386
+
387
+ vegetable_7: nil,
388
+
389
+ vegetable_8: nil,
390
+
391
+ vegetable_9: nil,
392
+
393
+ vegetable_10: nil,
394
+
395
+ vegetable_11: nil,
396
+
397
+ vegetable_12: nil,
398
+
399
+ vegetable_13: nil,
400
+
401
+ vegetable_14: nil,
402
+
403
+ vegetable_15: nil,
404
+
405
+ recipe_id: nil,
406
+
407
+ created_at: nil,
408
+
409
+ updated_at: nil>,
410
+
411
+ #<Material:0x00007feb099f41f0
412
+
413
+ id: nil,
414
+
415
+ vegetable_1: "mu",
416
+
417
+ vegetable_2: nil,
418
+
419
+ vegetable_3: nil,
420
+
421
+ vegetable_4: nil,
422
+
423
+ vegetable_5: nil,
424
+
425
+ vegetable_6: nil,
426
+
427
+ vegetable_7: nil,
428
+
429
+ vegetable_8: nil,
430
+
431
+ vegetable_9: nil,
432
+
433
+ vegetable_10: nil,
434
+
435
+ vegetable_11: nil,
436
+
437
+ vegetable_12: nil,
438
+
439
+ vegetable_13: nil,
440
+
441
+ vegetable_14: nil,
442
+
443
+ vegetable_15: nil,
444
+
445
+ recipe_id: nil,
446
+
447
+ created_at: nil,
448
+
449
+ updated_at: nil>,
450
+
451
+ #<Material:0x00007feafc7d3ae0
452
+
453
+ id: nil,
454
+
455
+ vegetable_1: "gi",
456
+
457
+ vegetable_2: nil,
458
+
459
+ vegetable_3: nil,
460
+
461
+ vegetable_4: nil,
462
+
463
+ vegetable_5: nil,
464
+
465
+ vegetable_6: nil,
466
+
467
+ vegetable_7: nil,
468
+
469
+ vegetable_8: nil,
470
+
471
+ vegetable_9: nil,
472
+
473
+ vegetable_10: nil,
474
+
475
+ vegetable_11: nil,
476
+
477
+ vegetable_12: nil,
478
+
479
+ vegetable_13: nil,
480
+
481
+ vegetable_14: nil,
482
+
483
+ vegetable_15: nil,
484
+
485
+ recipe_id: nil,
486
+
487
+ [3] pry(#<RecipesController>)> exit
488
+
489
+ ```
490
+
491
+
492
+
493
+
328
494
 
329
495
  どうにか保存できる形にしたいです。
330
496