質問編集履歴
8
correct_user,destroyを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -350,11 +350,39 @@
|
|
350
350
|
|
351
351
|
|
352
352
|
|
353
|
+
def new
|
354
|
+
|
355
|
+
@its = ItCollection.new(current_user)
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
def create
|
362
|
+
|
363
|
+
@its = ItCollection.new(current_user, its_params)
|
364
|
+
|
365
|
+
if @its.save
|
366
|
+
|
367
|
+
flash[:success] = '成功しました!'
|
368
|
+
|
369
|
+
redirect_to it_path(current_user)
|
370
|
+
|
371
|
+
else
|
372
|
+
|
373
|
+
render 'new'
|
374
|
+
|
375
|
+
end
|
376
|
+
|
377
|
+
end
|
378
|
+
|
379
|
+
|
380
|
+
|
353
381
|
def destroy
|
354
382
|
|
355
|
-
@it
|
383
|
+
@it.destroy
|
356
|
-
|
384
|
+
|
357
|
-
flash[:danger] = "
|
385
|
+
flash[:danger] = "#{@its.situation}削除しました!"
|
358
386
|
|
359
387
|
redirect_to request.referrer || root_url
|
360
388
|
|
@@ -362,27 +390,27 @@
|
|
362
390
|
|
363
391
|
|
364
392
|
|
365
|
-
def
|
393
|
+
def edit
|
366
|
-
|
394
|
+
|
367
|
-
@its =
|
395
|
+
@its = current_user.its
|
368
|
-
|
396
|
+
|
369
|
-
end
|
397
|
+
end
|
370
|
-
|
371
|
-
|
372
|
-
|
398
|
+
|
399
|
+
|
400
|
+
|
373
|
-
def
|
401
|
+
def update
|
374
|
-
|
402
|
+
|
375
|
-
@its =
|
403
|
+
@its = current_user.its
|
376
|
-
|
404
|
+
|
377
|
-
if @its.sa
|
405
|
+
if @its.update(its_params)
|
378
|
-
|
406
|
+
|
379
|
-
flash[:success] =
|
407
|
+
flash[:success] = "編集しました!"
|
380
408
|
|
381
409
|
redirect_to it_path(current_user)
|
382
410
|
|
383
411
|
else
|
384
412
|
|
385
|
-
render '
|
413
|
+
render 'its/edit'
|
386
414
|
|
387
415
|
end
|
388
416
|
|
@@ -390,27 +418,83 @@
|
|
390
418
|
|
391
419
|
|
392
420
|
|
421
|
+
private
|
422
|
+
|
423
|
+
|
424
|
+
|
393
|
-
def
|
425
|
+
def its_params
|
394
|
-
|
426
|
+
|
395
|
-
|
427
|
+
params.slice(:its).permit(its: [:situation, :behavior]).require(:its)
|
396
|
-
|
428
|
+
|
397
|
-
end
|
429
|
+
end
|
398
|
-
|
399
|
-
|
400
|
-
|
430
|
+
|
431
|
+
|
432
|
+
|
401
|
-
def u
|
433
|
+
def correct_user
|
434
|
+
|
402
|
-
|
435
|
+
@it = current_user.its.find_by(id: params[:id])
|
436
|
+
|
437
|
+
redirect_to root_url if @it.nil?
|
438
|
+
|
439
|
+
end
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
end
|
444
|
+
|
445
|
+
```
|
446
|
+
|
447
|
+
**app/helpers/sessions_helpers.rb**
|
448
|
+
|
449
|
+
```ここに言語を入力
|
450
|
+
|
451
|
+
module SessionsHelper
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
# 渡されたユーザーでログインする
|
456
|
+
|
457
|
+
def log_in(user)
|
458
|
+
|
459
|
+
session[:user_id] = user.id
|
460
|
+
|
461
|
+
end
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
# ユーザーのセッションを永続的にする
|
466
|
+
|
467
|
+
def remember(user)
|
468
|
+
|
469
|
+
user.remember
|
470
|
+
|
471
|
+
cookies.permanent.signed[:user_id] = user.id
|
472
|
+
|
473
|
+
cookies.permanent[:remember_token] = user.remember_token
|
474
|
+
|
475
|
+
end
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
# 記憶トークンcookieに対応するユーザーを返す
|
480
|
+
|
403
|
-
|
481
|
+
def current_user
|
404
|
-
|
482
|
+
|
405
|
-
if
|
483
|
+
if (user_id = session[:user_id])
|
406
|
-
|
407
|
-
|
484
|
+
|
408
|
-
|
409
|
-
r
|
485
|
+
@current_user ||= User.find_by(id: user_id)
|
486
|
+
|
410
|
-
|
487
|
+
elsif (user_id = cookies.signed[:user_id])
|
488
|
+
|
489
|
+
user = User.find_by(id: user_id)
|
490
|
+
|
491
|
+
if user && user.authenticated?(cookies[:remember_token])
|
492
|
+
|
493
|
+
log_in user
|
494
|
+
|
495
|
+
@current_user = user
|
496
|
+
|
411
|
-
e
|
497
|
+
end
|
412
|
-
|
413
|
-
render 'its/edit'
|
414
498
|
|
415
499
|
end
|
416
500
|
|
@@ -418,176 +502,92 @@
|
|
418
502
|
|
419
503
|
|
420
504
|
|
421
|
-
|
505
|
+
# 渡されたユーザーがログイン済みユーザーであればtrueを返す
|
422
|
-
|
423
|
-
|
424
|
-
|
506
|
+
|
425
|
-
def
|
507
|
+
def current_user?(user)
|
426
|
-
|
508
|
+
|
427
|
-
|
509
|
+
user == current_user
|
428
|
-
|
510
|
+
|
429
|
-
end
|
511
|
+
end
|
512
|
+
|
513
|
+
|
514
|
+
|
430
|
-
|
515
|
+
# ユーザーがログインしていればtrue、その他ならfalseを返す
|
431
|
-
|
432
|
-
|
516
|
+
|
433
|
-
def
|
517
|
+
def logged_in?
|
434
|
-
|
435
|
-
|
518
|
+
|
436
|
-
|
437
|
-
r
|
519
|
+
!current_user.nil?
|
438
|
-
|
520
|
+
|
439
|
-
end
|
521
|
+
end
|
522
|
+
|
523
|
+
|
524
|
+
|
440
|
-
|
525
|
+
# 永続的セッションを破棄する
|
526
|
+
|
441
|
-
|
527
|
+
def forget(user)
|
528
|
+
|
529
|
+
user.forget
|
530
|
+
|
531
|
+
cookies.delete(:user_id)
|
532
|
+
|
533
|
+
cookies.delete(:remember_token)
|
534
|
+
|
535
|
+
end
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
# 現在のユーザーをログアウトする
|
540
|
+
|
541
|
+
def log_out
|
542
|
+
|
543
|
+
forget(current_user)
|
544
|
+
|
545
|
+
session.delete(:user_id)
|
546
|
+
|
547
|
+
@current_user = nil
|
548
|
+
|
549
|
+
end
|
442
550
|
|
443
551
|
end
|
444
552
|
|
445
553
|
```
|
446
554
|
|
555
|
+
|
556
|
+
|
447
|
-
**
|
557
|
+
**ログ**
|
448
558
|
|
449
559
|
```ここに言語を入力
|
450
560
|
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
#
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
e
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
co
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
# 記憶トークンcookieに対応するユーザーを返す
|
480
|
-
|
481
|
-
def current_user
|
482
|
-
|
483
|
-
if (user_id = session[:user_id])
|
484
|
-
|
485
|
-
@current_user ||= User.find_by(id: user_id)
|
486
|
-
|
487
|
-
elsif (user_id = cookies.signed[:user_id])
|
488
|
-
|
489
|
-
user = User.find_by(id: user_id)
|
490
|
-
|
491
|
-
if user && user.authenticated?(cookies[:remember_token])
|
492
|
-
|
493
|
-
log_in user
|
494
|
-
|
495
|
-
@current_user = user
|
496
|
-
|
497
|
-
end
|
498
|
-
|
499
|
-
end
|
500
|
-
|
501
|
-
end
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
# 渡されたユーザーがログイン済みユーザーであればtrueを返す
|
506
|
-
|
507
|
-
def current_user?(user)
|
508
|
-
|
509
|
-
user == current_user
|
510
|
-
|
511
|
-
end
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
# ユーザーがログインしていればtrue、その他ならfalseを返す
|
516
|
-
|
517
|
-
def logged_in?
|
518
|
-
|
519
|
-
!current_user.nil?
|
520
|
-
|
521
|
-
end
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
# 永続的セッションを破棄する
|
526
|
-
|
527
|
-
def forget(user)
|
528
|
-
|
529
|
-
user.forget
|
530
|
-
|
531
|
-
cookies.delete(:user_id)
|
532
|
-
|
533
|
-
cookies.delete(:remember_token)
|
534
|
-
|
535
|
-
end
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
# 現在のユーザーをログアウトする
|
540
|
-
|
541
|
-
def log_out
|
542
|
-
|
543
|
-
forget(current_user)
|
544
|
-
|
545
|
-
session.delete(:user_id)
|
546
|
-
|
547
|
-
@current_user = nil
|
548
|
-
|
549
|
-
end
|
550
|
-
|
551
|
-
end
|
552
|
-
|
553
|
-
```
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
**ログ**
|
561
|
+
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-11 05:52:21 +0000
|
562
|
+
|
563
|
+
web_1 | Cannot render console from 172.19.0.1! Allowed networks: 172.18.0.1, 127.0.0.0/127.255.255.255, ::1
|
564
|
+
|
565
|
+
web_1 | Processing by ItsController#update as HTML
|
566
|
+
|
567
|
+
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"/MDK5kbE0pqSh6uHKcWA==", "its"=>{"39"=>{"situation"=>"Situation1", "behavior"=>"Behavior1"},
|
568
|
+
|
569
|
+
"40"=>{"situation"=>"Situation4", "behavior"=>"Behavior4"}, "41"=>{"situation"=>"Situation8", "behavior"=>"Behavior8"}}, "commit"=>"一括編集", "id"=>"8"}
|
570
|
+
|
571
|
+
web_1 | User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 LIMIT 1
|
572
|
+
|
573
|
+
web_1 | It Load (0.4ms) SELECT `its`.* FROM `its` WHERE `its`.`user_id` = 8 ORDER BY `its`.`created_at` DESC
|
574
|
+
|
575
|
+
web_1 | (0.2ms) BEGIN
|
576
|
+
|
577
|
+
web_1 | (0.2ms) ROLLBACK
|
578
|
+
|
579
|
+
web_1 | Completed 500 Internal Server Error in 112ms (ActiveRecord: 3.2ms)
|
580
|
+
|
581
|
+
web_1 | ActiveModel::UnknownAttributeError - unknown attribute '39' for It.:
|
582
|
+
|
583
|
+
web_1 | app/controllers/its_controller.rb:44:in `update'
|
584
|
+
|
585
|
+
```
|
586
|
+
|
587
|
+
### **環境**
|
558
588
|
|
559
589
|
```ここに言語を入力
|
560
590
|
|
561
|
-
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-11 05:52:21 +0000
|
562
|
-
|
563
|
-
web_1 | Cannot render console from 172.19.0.1! Allowed networks: 172.18.0.1, 127.0.0.0/127.255.255.255, ::1
|
564
|
-
|
565
|
-
web_1 | Processing by ItsController#update as HTML
|
566
|
-
|
567
|
-
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"/MDK5kbE0pqSh6uHKcWA==", "its"=>{"39"=>{"situation"=>"Situation1", "behavior"=>"Behavior1"},
|
568
|
-
|
569
|
-
"40"=>{"situation"=>"Situation4", "behavior"=>"Behavior4"}, "41"=>{"situation"=>"Situation8", "behavior"=>"Behavior8"}}, "commit"=>"一括編集", "id"=>"8"}
|
570
|
-
|
571
|
-
web_1 | User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 LIMIT 1
|
572
|
-
|
573
|
-
web_1 | It Load (0.4ms) SELECT `its`.* FROM `its` WHERE `its`.`user_id` = 8 ORDER BY `its`.`created_at` DESC
|
574
|
-
|
575
|
-
web_1 | (0.2ms) BEGIN
|
576
|
-
|
577
|
-
web_1 | (0.2ms) ROLLBACK
|
578
|
-
|
579
|
-
web_1 | Completed 500 Internal Server Error in 112ms (ActiveRecord: 3.2ms)
|
580
|
-
|
581
|
-
web_1 | ActiveModel::UnknownAttributeError - unknown attribute '39' for It.:
|
582
|
-
|
583
|
-
web_1 | app/controllers/its_controller.rb:44:in `update'
|
584
|
-
|
585
|
-
```
|
586
|
-
|
587
|
-
### **環境**
|
588
|
-
|
589
|
-
```ここに言語を入力
|
590
|
-
|
591
591
|
rails: 5.2.3
|
592
592
|
|
593
593
|
ruby: 2.5.7
|
7
タイトルの微編集
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
unknown attribute '
|
1
|
+
unknown attribute '' for It..と出て一括編集できない
|
test
CHANGED
@@ -584,7 +584,7 @@
|
|
584
584
|
|
585
585
|
```
|
586
586
|
|
587
|
-
**環境**
|
587
|
+
### **環境**
|
588
588
|
|
589
589
|
```ここに言語を入力
|
590
590
|
|
6
指摘されたところの修正(ログ、コントローラー、エラー画面)
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
unknown attribute '
|
1
|
+
unknown attribute '39' for It..と出て一括編集できない
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Railsで一括編集する機能を開発しています。
|
8
8
|
|
9
|
-
一括で編集する際に、unknown attribute '
|
9
|
+
一括で編集する際に、unknown attribute '39' for It.. エラーが出て編集できません。
|
10
10
|
|
11
11
|
StrongParameter周辺に問題があるのはわかるのですが、どのようにすればよいかわかりません。
|
12
12
|
|
@@ -14,15 +14,19 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
|
17
|
+
###問題が発生するまでの流れ・手順
|
18
18
|
|
19
19
|
一括で編集するボタンを押した時
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
エラーメッセージ
|
23
|
+
### エラーメッセージ
|
24
|
-
|
24
|
+
|
25
|
-
![イメージ説明](
|
25
|
+
![イメージ説明](549af9cdac2f6a2863163b417d995810.png)
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
### ソースコード
|
26
30
|
|
27
31
|
|
28
32
|
|
@@ -420,7 +424,7 @@
|
|
420
424
|
|
421
425
|
def its_params
|
422
426
|
|
423
|
-
params.slice(:its).permit(its: [:situation, :behavior])
|
427
|
+
params.slice(:its).permit(its: [:situation, :behavior]).require(:its)
|
424
428
|
|
425
429
|
end
|
426
430
|
|
@@ -544,30 +548,6 @@
|
|
544
548
|
|
545
549
|
end
|
546
550
|
|
547
|
-
|
548
|
-
|
549
|
-
# 記憶したURL (もしくはデフォルト値) にリダイレクト(フレンドリーフォワーディング)
|
550
|
-
|
551
|
-
def redirect_back_or(default)
|
552
|
-
|
553
|
-
redirect_to(session[:forwarding_url] || default)
|
554
|
-
|
555
|
-
session.delete(:forwarding_url)
|
556
|
-
|
557
|
-
end
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
# アクセスしようとしたURLを覚えておく
|
562
|
-
|
563
|
-
def store_location
|
564
|
-
|
565
|
-
session[:forwarding_url] = request.original_url if request.get?
|
566
|
-
|
567
|
-
end
|
568
|
-
|
569
|
-
|
570
|
-
|
571
551
|
end
|
572
552
|
|
573
553
|
```
|
@@ -578,32 +558,30 @@
|
|
578
558
|
|
579
559
|
```ここに言語を入力
|
580
560
|
|
581
|
-
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-11 0
|
561
|
+
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-11 05:52:21 +0000
|
582
562
|
|
583
563
|
web_1 | Cannot render console from 172.19.0.1! Allowed networks: 172.18.0.1, 127.0.0.0/127.255.255.255, ::1
|
584
564
|
|
585
|
-
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
|
586
|
-
|
587
565
|
web_1 | Processing by ItsController#update as HTML
|
588
566
|
|
589
|
-
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"
|
567
|
+
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"/MDK5kbE0pqSh6uHKcWA==", "its"=>{"39"=>{"situation"=>"Situation1", "behavior"=>"Behavior1"},
|
568
|
+
|
569
|
+
"40"=>{"situation"=>"Situation4", "behavior"=>"Behavior4"}, "41"=>{"situation"=>"Situation8", "behavior"=>"Behavior8"}}, "commit"=>"一括編集", "id"=>"8"}
|
590
570
|
|
591
571
|
web_1 | User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 LIMIT 1
|
592
572
|
|
593
|
-
web_1 | It Load (0.
|
573
|
+
web_1 | It Load (0.4ms) SELECT `its`.* FROM `its` WHERE `its`.`user_id` = 8 ORDER BY `its`.`created_at` DESC
|
594
574
|
|
595
575
|
web_1 | (0.2ms) BEGIN
|
596
576
|
|
597
577
|
web_1 | (0.2ms) ROLLBACK
|
598
578
|
|
599
|
-
web_1 | Completed 500 Internal Server Error in 112ms (ActiveRecord:
|
579
|
+
web_1 | Completed 500 Internal Server Error in 112ms (ActiveRecord: 3.2ms)
|
600
|
-
|
580
|
+
|
601
|
-
web_1 | ActiveModel::UnknownAttributeError - unknown attribute '
|
581
|
+
web_1 | ActiveModel::UnknownAttributeError - unknown attribute '39' for It.:
|
602
582
|
|
603
583
|
web_1 | app/controllers/its_controller.rb:44:in `update'
|
604
584
|
|
605
|
-
|
606
|
-
|
607
585
|
```
|
608
586
|
|
609
587
|
**環境**
|
5
エラー画面の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
エラーメッセージ
|
24
24
|
|
25
|
-
![
|
25
|
+
![イメージ説明](b5ad36ea51a2a3a3b7d6980853d8523f.png)
|
26
26
|
|
27
27
|
|
28
28
|
|
4
指摘されたところの修正(ログ、コントローラー、
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
unknown attribute 'its' for It.と出て一括編集できない
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Railsで一括編集する機能を開発しています。
|
8
8
|
|
9
|
-
一括で編集する際に、
|
9
|
+
一括で編集する際に、unknown attribute 'its' for It. エラーが出て編集できません。
|
10
10
|
|
11
11
|
StrongParameter周辺に問題があるのはわかるのですが、どのようにすればよいかわかりません。
|
12
12
|
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
エラーメッセージ
|
24
24
|
|
25
|
-
![イメージ説明](ed855ea66d7585c19b1dbf29e9c4a45a.png)
|
25
|
+
![![イメージ説明](ed855ea66d7585c19b1dbf29e9c4a45a.png)]
|
26
26
|
|
27
27
|
|
28
28
|
|
@@ -420,7 +420,7 @@
|
|
420
420
|
|
421
421
|
def its_params
|
422
422
|
|
423
|
-
params.permit(its: [:situation, :behavior])
|
423
|
+
params.slice(:its).permit(its: [:situation, :behavior])
|
424
424
|
|
425
425
|
end
|
426
426
|
|
@@ -578,34 +578,30 @@
|
|
578
578
|
|
579
579
|
```ここに言語を入力
|
580
580
|
|
581
|
-
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-10
|
581
|
+
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-11 01:06:06 +0000
|
582
582
|
|
583
583
|
web_1 | Cannot render console from 172.19.0.1! Allowed networks: 172.18.0.1, 127.0.0.0/127.255.255.255, ::1
|
584
584
|
|
585
|
-
web_1 | (
|
585
|
+
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
|
586
586
|
|
587
587
|
web_1 | Processing by ItsController#update as HTML
|
588
588
|
|
589
|
-
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"TaBlSx7n
|
590
|
-
|
591
|
-
web_1 | User Load (
|
592
|
-
|
593
|
-
web_1 |
|
594
|
-
|
595
|
-
web_1 |
|
596
|
-
|
597
|
-
web_1 |
|
598
|
-
|
599
|
-
web_1 |
|
600
|
-
|
601
|
-
web_1 | Actio
|
602
|
-
|
603
|
-
web_1 | app/controllers/its_controller.rb:57:in `its_params'
|
589
|
+
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"TaBlSx7nndJWZUyIUUmL+tGZpUKyHnrPPU2sRf8sGsLw==", "its"=>{"27"=>{"situation"=>"Situation4", "behavior"=>"Behavior4"}, "28"=>{"situation"=>"Situation5", "behavior"=>"Behavior5"}, "29"=>{"situation"=>"Situation6", "behavior"=>"Behavior6"}}, "commit"=>"一括編集", "id"=>"8"}
|
590
|
+
|
591
|
+
web_1 | User Load (0.2ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 LIMIT 1
|
592
|
+
|
593
|
+
web_1 | It Load (0.5ms) SELECT `its`.* FROM `its` WHERE `its`.`user_id` = 8 ORDER BY `its`.`created_at` DESC
|
594
|
+
|
595
|
+
web_1 | (0.2ms) BEGIN
|
596
|
+
|
597
|
+
web_1 | (0.2ms) ROLLBACK
|
598
|
+
|
599
|
+
web_1 | Completed 500 Internal Server Error in 112ms (ActiveRecord: 4.1ms)
|
600
|
+
|
601
|
+
web_1 | ActiveModel::UnknownAttributeError - unknown attribute 'its' for It.:
|
604
602
|
|
605
603
|
web_1 | app/controllers/its_controller.rb:44:in `update'
|
606
604
|
|
607
|
-
web_1 |
|
608
|
-
|
609
605
|
|
610
606
|
|
611
607
|
```
|
3
ログの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -578,56 +578,36 @@
|
|
578
578
|
|
579
579
|
```ここに言語を入力
|
580
580
|
|
581
|
-
web_1 | Started
|
581
|
+
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-10 23:55:17 +0000
|
582
582
|
|
583
583
|
web_1 | Cannot render console from 172.19.0.1! Allowed networks: 172.18.0.1, 127.0.0.0/127.255.255.255, ::1
|
584
584
|
|
585
|
-
web_1 |
|
586
|
-
|
587
|
-
web_1 | Parameters: {"id"=>"8"}
|
588
|
-
|
589
|
-
web_1 | User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 LIMIT 1
|
590
|
-
|
591
|
-
web_1 | Rendering its/edit.html.erb within layouts/application
|
592
|
-
|
593
|
-
web_1 | It Load (0.5ms) SELECT `its`.* FROM `its` WHERE `its`.`user_id` = 8 AND (8) ORDER BY `its`.`created_at` DESC
|
594
|
-
|
595
|
-
web_1 | Rendered its/edit.html.erb within layouts/application (38.1ms)
|
596
|
-
|
597
|
-
web_1 | Rendered layouts/_shim.html.erb (0.5ms)
|
598
|
-
|
599
|
-
web_1 | Rendered layouts/_head.html.erb (521.8ms)
|
600
|
-
|
601
|
-
web_1 | Rendered layouts/_header.html.erb (7.2ms)
|
602
|
-
|
603
|
-
web_1 | Rendered layouts/_flash_messages.html.erb (0.6ms)
|
604
|
-
|
605
|
-
web_1 | Rendered layouts/_footer.html.erb (5.3ms)
|
606
|
-
|
607
|
-
web_1 | Completed 200 OK in 800ms (Views: 673.9ms | ActiveRecord: 3.9ms)
|
608
|
-
|
609
|
-
web_1 | Started PATCH "/its/8" for 172.19.0.1 at 2020-09-10 14:18:07 +0000
|
610
|
-
|
611
|
-
web_1 | Cannot render console from 172.19.0.1! Allowed networks: 172.18.0.1, 127.0.0.0/127.255.255.255, ::1
|
585
|
+
web_1 | (1.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
|
612
586
|
|
613
587
|
web_1 | Processing by ItsController#update as HTML
|
614
588
|
|
615
|
-
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"7
|
616
|
-
|
617
|
-
web_1 | User Load (0
|
618
|
-
|
619
|
-
web_1 | It
|
620
|
-
|
621
|
-
web_1 |
|
622
|
-
|
623
|
-
web_1 |
|
624
|
-
|
625
|
-
web_1 |
|
626
|
-
|
627
|
-
web_1 | Acti
|
589
|
+
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"TaBlSx7n0l8LSo7l0C/2hlJSaS4sd5XviXo1oirYQZp21I3TEjndJWZUyIUUmL+tGZpUKyHnrPPU2sRf8sGsLw==", "its"=>{"27"=>{"situation"=>"Situation4", "behavior"=>"Behavior4"}, "28"=>{"situation"=>"Situation5", "behavior"=>"Behavior5"}, "29"=>{"situation"=>"Situation6", "behavior"=>"Behavior6"}}, "commit"=>"一括編集", "id"=>"8"}
|
590
|
+
|
591
|
+
web_1 | User Load (1.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 8 LIMIT 1
|
592
|
+
|
593
|
+
web_1 | Completed 500 Internal Server Error in 204ms (ActiveRecord: 5.5ms)
|
594
|
+
|
595
|
+
web_1 |
|
596
|
+
|
597
|
+
web_1 |
|
598
|
+
|
599
|
+
web_1 |
|
600
|
+
|
601
|
+
web_1 | ActionController::UnpermittedParameters - found unpermitted parameters: :utf8, :_method, :authenticity_token, :commit, :id:
|
602
|
+
|
603
|
+
web_1 | app/controllers/its_controller.rb:57:in `its_params'
|
628
604
|
|
629
605
|
web_1 | app/controllers/its_controller.rb:44:in `update'
|
630
606
|
|
607
|
+
web_1 |
|
608
|
+
|
609
|
+
|
610
|
+
|
631
611
|
```
|
632
612
|
|
633
613
|
**環境**
|
2
タイトルの編集
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
found unpermitted parameters:と出て一括編集できない
|
test
CHANGED
File without changes
|
1
指摘されたところの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
Railsで一括編集する機能を開発しています。
|
8
8
|
|
9
|
-
一括で編集する際に、
|
9
|
+
一括で編集する際に、found unpermitted parameters: エラーが出て編集できません。
|
10
10
|
|
11
11
|
StrongParameter周辺に問題があるのはわかるのですが、どのようにすればよいかわかりません。
|
12
12
|
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
エラーメッセージ
|
24
24
|
|
25
|
-
![イメージ説明](e856
|
25
|
+
![イメージ説明](ed855ea66d7585c19b1dbf29e9c4a45a.png)
|
26
26
|
|
27
27
|
|
28
28
|
|
@@ -388,7 +388,7 @@
|
|
388
388
|
|
389
389
|
def edit
|
390
390
|
|
391
|
-
@its = current_user.its
|
391
|
+
@its = current_user.its
|
392
392
|
|
393
393
|
end
|
394
394
|
|
@@ -396,7 +396,7 @@
|
|
396
396
|
|
397
397
|
def update
|
398
398
|
|
399
|
-
@its = current_user.its
|
399
|
+
@its = current_user.its
|
400
400
|
|
401
401
|
if @its.update(its_params)
|
402
402
|
|
@@ -420,7 +420,7 @@
|
|
420
420
|
|
421
421
|
def its_params
|
422
422
|
|
423
|
-
params.r
|
423
|
+
params.permit(its: [:situation, :behavior])
|
424
424
|
|
425
425
|
end
|
426
426
|
|