質問編集履歴

3

エラー部分の補足

2020/04/14 05:07

投稿

ren0826nosuke
ren0826nosuke

スコア34

test CHANGED
File without changes
test CHANGED
@@ -158,6 +158,8 @@
158
158
 
159
159
  <%= form.select :category_id, @category.map{|category|[category.name,category.id]} %>
160
160
 
161
+      #上記selectの部分がエラー該当箇所です。
162
+
161
163
  </div>
162
164
 
163
165
 

2

新たなエラー部分の追記

2020/04/14 05:07

投稿

ren0826nosuke
ren0826nosuke

スコア34

test CHANGED
File without changes
test CHANGED
@@ -124,6 +124,110 @@
124
124
 
125
125
  ```
126
126
 
127
+ 新たに出たエラー全文
128
+
129
+ ```ruby
130
+
131
+ NoMethodError in Targets#create
132
+
133
+ Showing /Users/ren0826nosuke/Desktop/projects/target-app/app/views/targets/new.html.erb where line #10 raised:
134
+
135
+
136
+
137
+ undefined method `map' for nil:NilClass
138
+
139
+ Extracted source (around line #10):
140
+
141
+ 8
142
+
143
+ 9
144
+
145
+ 10
146
+
147
+ 11
148
+
149
+ 12
150
+
151
+ 13
152
+
153
+
154
+
155
+ <div class="form-group">
156
+
157
+ <%= form.label :category_id, "カテゴリ" %><br>
158
+
159
+ <%= form.select :category_id, @category.map{|category|[category.name,category.id]} %>
160
+
161
+ </div>
162
+
163
+
164
+
165
+ <div class="form-group">
166
+
167
+
168
+
169
+ Rails.root: /Users/ren0826nosuke/Desktop/projects/target-app
170
+
171
+
172
+
173
+ Application Trace | Framework Trace | Full Trace
174
+
175
+ app/views/targets/new.html.erb:10:in `block in _app_views_targets_new_html_erb__2269560302185157887_70138228332500'
176
+
177
+ app/views/targets/new.html.erb:2:in `_app_views_targets_new_html_erb__2269560302185157887_70138228332500'
178
+
179
+ app/controllers/targets_controller.rb:24:in `create'
180
+
181
+ Request
182
+
183
+ Parameters:
184
+
185
+
186
+
187
+ {"utf8"=>"✓",
188
+
189
+ "authenticity_token"=>"F5MW8QuNuGxrebg66IJL2TkYLX233VnhbnpqO1cvrFH05j6rkv8bN+GmxtrEJBWAKtIzHbtyzSVkACcDi6NBng==",
190
+
191
+ "target"=>
192
+
193
+ {"title"=>"aaaaa",
194
+
195
+ "category_id"=>"1",
196
+
197
+ "price"=>"100",
198
+
199
+ "date(1i)"=>"2020",
200
+
201
+ "date(2i)"=>"4",
202
+
203
+ "date(3i)"=>"14",
204
+
205
+ "memo"=>"",
206
+
207
+ "priority"=>"1",
208
+
209
+ "created_at(1i)"=>"2020",
210
+
211
+ "created_at(2i)"=>"4",
212
+
213
+ "created_at(3i)"=>"14"},
214
+
215
+ "commit"=>"作成"}
216
+
217
+ Toggle session dump
218
+
219
+ Toggle env dump
220
+
221
+ Response
222
+
223
+ Headers:
224
+
225
+
226
+
227
+ None
228
+
229
+ ```
230
+
127
231
 
128
232
 
129
233
  ## 試してみた事

1

エラー文を全部追記

2020/04/14 05:03

投稿

ren0826nosuke
ren0826nosuke

スコア34

test CHANGED
File without changes
test CHANGED
@@ -24,6 +24,108 @@
24
24
 
25
25
 
26
26
 
27
+ ## エラー全文
28
+
29
+
30
+
31
+ ```ruby
32
+
33
+ NameError in TargetsController#create
34
+
35
+ undefined local variable or method `target' for #<TargetsController:0x00007f94aa1117c8> Did you mean? target_url
36
+
37
+ Extracted source (around line #42):
38
+
39
+ 40
40
+
41
+ 41
42
+
43
+ 42
44
+
45
+ 43
46
+
47
+ 44
48
+
49
+ 45
50
+
51
+
52
+
53
+ private
54
+
55
+ def target_params
56
+
57
+ params.require(:target).permit(:title, :price, :date, :memo, :created_at).merge(category_id: target.category.id,priority: target.priority.id)
58
+
59
+ end
60
+
61
+
62
+
63
+ def move_to_index
64
+
65
+
66
+
67
+ Rails.root: /Users/ren0826nosuke/Desktop/projects/target-app
68
+
69
+
70
+
71
+ Application Trace | Framework Trace | Full Trace
72
+
73
+ app/controllers/targets_controller.rb:42:in `target_params'
74
+
75
+ app/controllers/targets_controller.rb:20:in `create'
76
+
77
+ Request
78
+
79
+ Parameters:
80
+
81
+
82
+
83
+ {"utf8"=>"✓",
84
+
85
+ "authenticity_token"=>"F5MW8QuNuGxrebg66IJL2TkYLX233VnhbnpqO1cvrFH05j6rkv8bN+GmxtrEJBWAKtIzHbtyzSVkACcDi6NBng==",
86
+
87
+ "target"=>
88
+
89
+ {"title"=>"aaaaa",
90
+
91
+ "category_id"=>"1",
92
+
93
+ "price"=>"100",
94
+
95
+ "date(1i)"=>"2020",
96
+
97
+ "date(2i)"=>"4",
98
+
99
+ "date(3i)"=>"14",
100
+
101
+ "memo"=>"",
102
+
103
+ "priority"=>"1",
104
+
105
+ "created_at(1i)"=>"2020",
106
+
107
+ "created_at(2i)"=>"4",
108
+
109
+ "created_at(3i)"=>"14"},
110
+
111
+ "commit"=>"作成"}
112
+
113
+ Toggle session dump
114
+
115
+ Toggle env dump
116
+
117
+ Response
118
+
119
+ Headers:
120
+
121
+
122
+
123
+ None
124
+
125
+ ```
126
+
127
+
128
+
27
129
  ## 試してみた事
28
130
 
29
131
  createアクションにbinding.pryでparamsの中身を見てみると以下の通りでした。