質問編集履歴

3

誤字

2022/05/25 14:33

投稿

sanrio.
sanrio.

スコア13

test CHANGED
File without changes
test CHANGED
@@ -6,19 +6,23 @@
6
6
 
7
7
  発生している問題・エラーメッセージ
8
8
 
9
+
10
+
9
11
  NoMethodError in PrototypesController#edit
10
12
  undefined method `user_id' for nil:NilClass
11
13
  Extracted source (around line #54):
12
14
 
15
+ ```
13
16
  def move_to_index
14
17
  unless if user_signed_in? current_user.id == @prototype.user_id
15
18
  redirect_to action: :index
16
19
  end
17
20
  end
21
+ ```
18
22
 
19
23
  該当のソースコード
20
24
 
21
- app/Controller/prototypesController
25
+ ```app/Controller/prototypesController
22
26
 
23
27
  class PrototypesController < ApplicationController
24
28
  before_action :authenticate_user!, only: [:new,:edit,:destroy]
@@ -78,7 +82,19 @@
78
82
  end
79
83
  end
80
84
  end
85
+ ```
81
86
 
82
87
  自分で調べたことや試したこと
88
+
89
+ 一番最後のところ
90
+ ```
91
+ def move_to_index
92
+ unless if user_signed_in? current_user.id == @prototype.user_id
93
+ redirect_to action: :index
94
+ end
95
+ end
96
+ ```
97
+
98
+ 上記の 『==』の中身を
83
99
  『現在ログインしている人==あるプロトタイプを投稿した人』
84
- の記述にするのが正解かと思ったがプログラミング用語にどう表記すればいいかわからない
100
+ の記述にするのが正解かと思ったがプログラミング用語にするとどう表記すればいいかわからない

2

誤字

2022/05/24 14:39

投稿

sanrio.
sanrio.

スコア13

test CHANGED
File without changes
test CHANGED
@@ -11,7 +11,7 @@
11
11
  Extracted source (around line #54):
12
12
 
13
13
  def move_to_index
14
- unless if user_signed_in? current_user.id == @prototype.user_id
14
+ unless if user_signed_in? current_user.id == @prototype.user_id
15
15
  redirect_to action: :index
16
16
  end
17
17
  end

1

誤字

2022/05/24 14:10

投稿

sanrio.
sanrio.

スコア13

test CHANGED
File without changes
test CHANGED
@@ -5,12 +5,16 @@
5
5
  ログインしている自分が自分の編集ページに直接入力するとエラーになってしまう
6
6
 
7
7
  発生している問題・エラーメッセージ
8
+
8
9
  NoMethodError in PrototypesController#edit
9
10
  undefined method `user_id' for nil:NilClass
10
- Extracted source (around line #54):
11
+ Extracted source (around line #54):
11
12
 
12
13
  def move_to_index
13
- unless @prototype.user_id == current_user.id
14
+ unless if user_signed_in? current_user.id == @prototype.user_id
15
+ redirect_to action: :index
16
+ end
17
+ end
14
18
 
15
19
  該当のソースコード
16
20
 
@@ -69,7 +73,7 @@
69
73
  end
70
74
 
71
75
  def move_to_index
72
- unless @prototype.user_id == current_user.id
76
+ unless if user_signed_in? current_user.id == @prototype.user_id
73
77
  redirect_to action: :index
74
78
  end
75
79
  end