質問編集履歴
5
コード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,416 +1,202 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
|
3
2
|
railsで作成しているアプリケーション内で、concern置いているプログラムを通してデータベースにデータを保存したい。
|
4
|
-
|
5
3
|
### 発生している問題・エラーメッセージ
|
6
|
-
|
7
4
|
concern下のプログラムが動かず、viewでNoMethodErrorが発生しています。
|
8
5
|
|
9
|
-
|
10
|
-
|
11
6
|
NoMethodErrorのエラーコード
|
12
|
-
|
13
|
-
```
|
7
|
+
```
|
14
|
-
|
15
8
|
ActionView::Template::Error (undefined method `each' for nil:NilClass):
|
16
|
-
|
17
9
|
1: <head>
|
18
|
-
|
19
10
|
2: <meta http-equiv='refresh' content='10'>
|
20
|
-
|
21
11
|
3: </head>
|
22
|
-
|
23
|
-
4: <h1>
|
12
|
+
4: <h1>title</h1>
|
24
|
-
|
25
13
|
6: <p>
|
26
|
-
|
27
14
|
7: <% @value.each do |rawdate| %>
|
28
|
-
|
29
15
|
8: [distance] <%= rawdate.distance %>
|
30
|
-
|
31
16
|
8: [time] <%= rawdate.time %><br>
|
32
|
-
|
33
17
|
9: <% end %>
|
34
|
-
|
35
18
|
10: <% @resultvalue.each do |result| %>
|
36
|
-
|
37
19
|
11: [ishuman] <%= result.ishuman %>
|
38
|
-
|
39
20
|
12: [iscar] <%= result.iscar %>
|
40
|
-
|
41
21
|
13: <% end %>
|
42
22
|
|
43
|
-
|
44
|
-
|
45
23
|
app/views/address/show.html.erb:11
|
46
24
|
|
47
25
|
|
48
26
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
27
|
Showing D:/rails/application/app/views/address/show.html.erb where line #11 raised:
|
54
28
|
|
55
|
-
|
56
|
-
|
57
29
|
undefined method `each' for nil:NilClass
|
58
|
-
|
59
|
-
```
|
30
|
+
```
|
60
|
-
|
61
31
|
### 調べた内容・試した内容
|
62
|
-
|
63
32
|
concern内のプログラムでresultテーブルにデータを入れたり、子クラスの中でrawdataテーブルからデータを取り出したりするプログラムを書きました。concern下のプログラムがcontroller内のinclude Processで動作してないと思われるためにviewでnomethoderrorが発生しています。
|
64
|
-
|
65
33
|
以下にcontrollerとconcern下に置かれているProcess.rbのプログラムを載せます。
|
66
|
-
|
67
34
|
### 該当のソースコード
|
68
35
|
|
69
|
-
|
70
|
-
|
71
36
|
```controller
|
72
|
-
|
73
37
|
require 'net/http'
|
74
|
-
|
75
38
|
require 'net/https'
|
76
|
-
|
77
39
|
require 'uri'
|
78
|
-
|
79
40
|
require 'json'
|
80
|
-
|
81
41
|
require 'date'
|
82
42
|
|
83
|
-
|
84
|
-
|
85
43
|
class AddressController < ApplicationController
|
86
|
-
|
87
44
|
include Process
|
88
|
-
|
89
45
|
def show
|
90
|
-
|
91
|
-
params = URI.encode_www_form({token: '
|
46
|
+
params = URI.encode_www_form({token: 'token'})
|
92
|
-
|
93
47
|
uri = URI.parse("https://api.sakura.io/datastore/v1/channels?#{params}")
|
94
48
|
|
95
|
-
|
96
|
-
|
97
49
|
@query = uri.query
|
98
|
-
|
99
50
|
puts "aaa"
|
100
|
-
|
101
51
|
response = Net::HTTP.start(uri.host,
|
102
|
-
|
103
52
|
use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
104
|
-
|
105
53
|
open_timeout: 5
|
106
|
-
|
107
54
|
){|https| https.get(uri.request_uri)}
|
108
55
|
|
109
|
-
|
110
|
-
|
111
56
|
begin
|
112
|
-
|
113
57
|
case response
|
114
|
-
|
115
58
|
# 成功した場合
|
116
|
-
|
117
59
|
when Net::HTTPSuccess
|
118
|
-
|
119
60
|
@result = JSON.parse(response.body)
|
120
|
-
|
121
61
|
for i in 0..99 do
|
122
|
-
|
123
62
|
@value = @result["results"][i]["value"]
|
124
|
-
|
125
63
|
cannel = @result["results"][i]["channel"]
|
126
|
-
|
127
64
|
if cannel == 0 then
|
128
|
-
|
129
65
|
Rawdate.create(:time => @value)
|
130
|
-
|
131
|
-
else
|
66
|
+
else
|
132
|
-
|
133
67
|
Rawdate.create(:distance => @value)
|
134
|
-
|
135
|
-
end
|
68
|
+
end
|
136
|
-
|
137
|
-
end
|
69
|
+
end
|
138
|
-
|
139
70
|
@size = @result["meta"]["count"]
|
140
|
-
|
141
71
|
@value = Rawdate.all
|
142
|
-
|
143
72
|
start_main()
|
144
|
-
|
145
73
|
calculation()
|
146
|
-
|
147
74
|
output()
|
148
|
-
|
149
75
|
|
150
|
-
|
151
76
|
when Net::HTTPRedirection
|
152
|
-
|
153
77
|
@message = "Redirection: code=#{response.code} message=#{response.message}"
|
154
|
-
|
155
78
|
# その他エラー
|
156
|
-
|
157
79
|
else
|
158
|
-
|
159
80
|
@message = "HTTP ERROR: code=#{response.code} message=#{response.message}"
|
160
|
-
|
161
81
|
end
|
162
|
-
|
163
82
|
# エラー時処理
|
164
|
-
|
165
83
|
rescue IOError => e
|
166
|
-
|
167
|
-
@message = e.message
|
84
|
+
@message = e.message
|
168
|
-
|
169
85
|
rescue TimeoutError => e
|
170
|
-
|
171
|
-
@message = e.message
|
86
|
+
@message = e.message
|
172
|
-
|
173
87
|
rescue JSON::ParserError => e
|
174
|
-
|
175
|
-
@message = e.message
|
88
|
+
@message = e.message
|
176
|
-
|
177
89
|
rescue => e
|
178
|
-
|
179
|
-
@message = e.message
|
90
|
+
@message = e.message
|
180
|
-
|
181
|
-
end
|
91
|
+
end
|
182
|
-
|
183
92
|
end
|
184
|
-
|
185
93
|
end
|
186
|
-
|
187
|
-
```
|
94
|
+
```
|
188
|
-
|
189
|
-
|
190
95
|
|
191
96
|
```Process
|
192
|
-
|
193
97
|
module Process
|
194
|
-
|
195
98
|
|
196
|
-
|
197
99
|
extend ActiveSupport::Concern
|
198
|
-
|
199
100
|
|
200
|
-
|
201
101
|
require_relative 'read/read_main'
|
202
|
-
|
203
102
|
require_relative 'object_data/object_data'
|
204
|
-
|
205
103
|
require_relative 'number_data/number_data_main'
|
206
|
-
|
207
104
|
require_relative 'S_D_data/S_D_data_main'
|
208
|
-
|
209
105
|
require_relative 'transit_time/transit_data_main'
|
210
|
-
|
211
106
|
require_relative 'range_data/range_main'
|
212
|
-
|
213
107
|
require_relative 'count/count_main'
|
214
|
-
|
215
108
|
require_relative 'write/write_main'
|
216
109
|
|
217
|
-
|
218
|
-
|
219
110
|
def start_main
|
220
|
-
|
221
111
|
file_read = Read_main.new
|
222
|
-
|
223
112
|
write = Write_main.new
|
224
|
-
|
225
113
|
#p file_read.start_time
|
226
|
-
|
227
114
|
#p file_read.sensing_dis
|
228
|
-
|
229
115
|
#p file_read.data_cnt
|
230
|
-
|
231
116
|
p file_read.main
|
232
|
-
|
233
|
-
|
234
|
-
|
117
|
+
|
235
118
|
object_data = Object_data.new(file_read.main, file_read.data_cnt)
|
236
|
-
|
237
119
|
print "\n---------------object_data------------------\n"
|
238
|
-
|
239
120
|
#p object_data.main
|
240
|
-
|
241
121
|
object_data.drow
|
242
|
-
|
243
122
|
print "\n--------------------------------------------\n"
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
123
|
+
|
124
|
+
|
249
125
|
q_flag = 0
|
250
|
-
|
251
|
-
|
252
|
-
|
126
|
+
|
253
127
|
count = Count_main.new(object_data.main)
|
254
|
-
|
255
|
-
|
256
|
-
|
128
|
+
|
257
129
|
#p count.count_number #データの個数
|
258
|
-
|
259
130
|
#exit
|
260
|
-
|
261
|
-
end
|
131
|
+
end
|
262
|
-
|
263
|
-
|
264
132
|
|
265
133
|
def calculation
|
266
|
-
|
267
134
|
count.count_number.times do |i|
|
268
|
-
|
269
135
|
weight = 0
|
270
|
-
|
271
136
|
number_data = Number_main.new(object_data.main)
|
272
|
-
|
273
137
|
if number_data.weight(i).class == Float
|
274
|
-
|
275
138
|
weight += number_data.weight(i)
|
276
|
-
|
277
139
|
else
|
278
|
-
|
279
140
|
q_flag = 1
|
280
|
-
|
281
|
-
end
|
141
|
+
end
|
282
|
-
|
283
|
-
|
284
|
-
|
142
|
+
|
285
|
-
if q_flag == 0
|
143
|
+
if q_flag == 0
|
286
|
-
|
287
144
|
s_d = S_D_main.new(object_data.main)
|
288
|
-
|
289
145
|
#p s_d.val(0)
|
290
|
-
|
291
146
|
#p s_d.weight(i)
|
292
|
-
|
293
147
|
if s_d.weight(i).class == Float
|
294
|
-
|
295
148
|
weight += s_d.weight(i)
|
296
|
-
|
297
|
-
else
|
149
|
+
else
|
298
|
-
|
299
150
|
q_flag = 1
|
300
|
-
|
301
|
-
end
|
151
|
+
end
|
302
|
-
|
303
|
-
end
|
152
|
+
end
|
304
|
-
|
305
|
-
|
306
|
-
|
153
|
+
|
307
|
-
if q_flag == 0
|
154
|
+
if q_flag == 0
|
308
|
-
|
309
155
|
transit_time = Transit_main.new(object_data.main)
|
310
|
-
|
311
156
|
if transit_time.weight(i).class == Float
|
312
|
-
|
313
|
-
printf("
|
157
|
+
printf("weight: %f\n", transit_time.weight(i))
|
314
|
-
|
315
158
|
weight += transit_time.weight(i)
|
316
|
-
|
317
|
-
else
|
159
|
+
else
|
318
|
-
|
319
|
-
printf("
|
160
|
+
printf("weight: ?\n")
|
320
|
-
|
321
161
|
q_flag = 1
|
322
|
-
|
323
|
-
end
|
162
|
+
end
|
324
|
-
|
325
|
-
end
|
163
|
+
end
|
326
|
-
|
327
|
-
|
328
|
-
|
164
|
+
|
329
|
-
if q_flag == 0
|
165
|
+
if q_flag == 0
|
330
|
-
|
331
166
|
range = Range_main.new(object_data.main)
|
332
|
-
|
333
167
|
#p range.val(0)
|
334
|
-
|
335
168
|
if range.weight(i).class == Float
|
336
|
-
|
337
|
-
printf("
|
169
|
+
printf("range: %f\n", range.weight(i))
|
338
|
-
|
339
170
|
weight += range.weight(i)
|
340
|
-
|
341
|
-
else
|
171
|
+
else
|
342
|
-
|
343
|
-
printf("
|
172
|
+
printf("range: ?\n")
|
344
|
-
|
345
173
|
q_flag = 1
|
346
|
-
|
347
|
-
end
|
174
|
+
end
|
348
|
-
|
349
|
-
end
|
175
|
+
end
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
176
|
+
|
177
|
+
|
355
|
-
if q_flag == 0
|
178
|
+
if q_flag == 0
|
356
|
-
|
357
|
-
printf("
|
179
|
+
printf("sum: %f\n", weight)
|
358
|
-
|
359
180
|
else
|
360
|
-
|
361
|
-
printf("
|
181
|
+
printf("sum: ?\n")
|
362
|
-
|
363
|
-
end
|
182
|
+
end
|
364
|
-
|
365
|
-
|
366
|
-
|
183
|
+
|
367
184
|
write.count_car_or_human(weight,q_flag)
|
368
|
-
|
369
|
-
|
370
|
-
|
185
|
+
|
371
186
|
q_flag = 0
|
372
187
|
|
373
|
-
|
374
|
-
|
375
188
|
end
|
376
|
-
|
377
|
-
end
|
189
|
+
end
|
378
|
-
|
379
|
-
|
380
190
|
|
381
191
|
def output
|
382
|
-
|
383
192
|
printf("\n---------------------result------------------------\n")
|
384
|
-
|
385
|
-
printf("全体のオブジェクト個数: %d \n",count.count_number)
|
386
|
-
|
387
|
-
printf("車であろう個数: %d \n",write.count_car)
|
388
|
-
|
389
|
-
printf("人であろう個数: %d \n",write.count_human)
|
390
|
-
|
391
|
-
printf("判定不可能なオブジェクトの個数: %d ",write.count_q)
|
392
|
-
|
393
|
-
printf("\n---------------------------------------------------\n")
|
394
|
-
|
395
193
|
Result.create(:ishuman => write.count_human)
|
396
|
-
|
397
194
|
Result.create(:iscar => write.count_car)
|
398
|
-
|
399
195
|
@resultvalue = Result.all
|
400
|
-
|
401
|
-
|
402
|
-
|
196
|
+
|
403
|
-
end
|
197
|
+
end
|
404
|
-
|
405
198
|
end
|
406
|
-
|
407
|
-
```
|
199
|
+
```
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
200
|
|
415
201
|
|
416
202
|
|
@@ -418,10 +204,6 @@
|
|
418
204
|
|
419
205
|
### 補足情報(FW/ツールのバージョンなど)
|
420
206
|
|
421
|
-
|
422
|
-
|
423
207
|
ruby 2.6.5.p114
|
424
|
-
|
425
208
|
rails 6.0.2.1
|
426
|
-
|
427
209
|
sqlite3 3.30.1
|
4
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -84,6 +84,8 @@
|
|
84
84
|
|
85
85
|
class AddressController < ApplicationController
|
86
86
|
|
87
|
+
include Process
|
88
|
+
|
87
89
|
def show
|
88
90
|
|
89
91
|
params = URI.encode_www_form({token: 'd80ab730-2ba7-4225-b81f-9a4d1732c39d'})
|
@@ -400,14 +402,6 @@
|
|
400
402
|
|
401
403
|
end
|
402
404
|
|
403
|
-
|
404
|
-
|
405
|
-
class AddressController < ApplicationController
|
406
|
-
|
407
|
-
include Process
|
408
|
-
|
409
|
-
end
|
410
|
-
|
411
405
|
end
|
412
406
|
|
413
407
|
```
|
3
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,39 +78,31 @@
|
|
78
78
|
|
79
79
|
require 'json'
|
80
80
|
|
81
|
+
require 'date'
|
82
|
+
|
81
83
|
|
82
84
|
|
83
85
|
class AddressController < ApplicationController
|
84
86
|
|
85
87
|
def show
|
86
88
|
|
87
|
-
params = URI.encode_www_form({token: '
|
89
|
+
params = URI.encode_www_form({token: 'd80ab730-2ba7-4225-b81f-9a4d1732c39d'})
|
88
|
-
|
89
|
-
|
90
|
+
|
90
|
-
|
91
|
-
uri = URI.parse("api
|
91
|
+
uri = URI.parse("https://api.sakura.io/datastore/v1/channels?#{params}")
|
92
|
-
|
93
|
-
|
94
|
-
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
-
|
95
|
+
@query = uri.query
|
96
96
|
|
97
97
|
puts "aaa"
|
98
98
|
|
99
|
-
# 新しくHTTPセッションを開始し、結果をresponseへ格納
|
100
|
-
|
101
99
|
response = Net::HTTP.start(uri.host,
|
102
100
|
|
103
101
|
use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
104
102
|
|
105
|
-
#response = https.start
|
106
|
-
|
107
|
-
# 接続時に待つ最大秒数を設定
|
108
|
-
|
109
103
|
open_timeout: 5
|
110
104
|
|
111
|
-
|
105
|
+
){|https| https.get(uri.request_uri)}
|
112
|
-
|
113
|
-
|
114
106
|
|
115
107
|
|
116
108
|
|
@@ -122,14 +114,8 @@
|
|
122
114
|
|
123
115
|
when Net::HTTPSuccess
|
124
116
|
|
125
|
-
# responseのbody要素をJSON形式で解釈し、hashに変換
|
126
|
-
|
127
|
-
puts "a"
|
128
|
-
|
129
117
|
@result = JSON.parse(response.body)
|
130
118
|
|
131
|
-
# 表示用の変数に結果を格納
|
132
|
-
|
133
119
|
for i in 0..99 do
|
134
120
|
|
135
121
|
@value = @result["results"][i]["value"]
|
@@ -150,11 +136,15 @@
|
|
150
136
|
|
151
137
|
@size = @result["meta"]["count"]
|
152
138
|
|
153
|
-
@value =
|
139
|
+
@value = Rawdate.all
|
140
|
+
|
154
|
-
|
141
|
+
start_main()
|
142
|
+
|
155
|
-
|
143
|
+
calculation()
|
156
|
-
|
144
|
+
|
157
|
-
|
145
|
+
output()
|
146
|
+
|
147
|
+
|
158
148
|
|
159
149
|
when Net::HTTPRedirection
|
160
150
|
|
@@ -230,6 +220,12 @@
|
|
230
220
|
|
231
221
|
write = Write_main.new
|
232
222
|
|
223
|
+
#p file_read.start_time
|
224
|
+
|
225
|
+
#p file_read.sensing_dis
|
226
|
+
|
227
|
+
#p file_read.data_cnt
|
228
|
+
|
233
229
|
p file_read.main
|
234
230
|
|
235
231
|
|
@@ -272,10 +268,6 @@
|
|
272
268
|
|
273
269
|
number_data = Number_main.new(object_data.main)
|
274
270
|
|
275
|
-
#p number_data.weight(i).class
|
276
|
-
|
277
|
-
#p number_data.weight(i)
|
278
|
-
|
279
271
|
if number_data.weight(i).class == Float
|
280
272
|
|
281
273
|
weight += number_data.weight(i)
|
@@ -314,14 +306,16 @@
|
|
314
306
|
|
315
307
|
transit_time = Transit_main.new(object_data.main)
|
316
308
|
|
317
|
-
#p transit_time.drow(0)
|
318
|
-
|
319
309
|
if transit_time.weight(i).class == Float
|
320
310
|
|
311
|
+
printf("経過時間重み: %f\n", transit_time.weight(i))
|
312
|
+
|
321
313
|
weight += transit_time.weight(i)
|
322
314
|
|
323
315
|
else
|
324
316
|
|
317
|
+
printf("経過時間重み: ?\n")
|
318
|
+
|
325
319
|
q_flag = 1
|
326
320
|
|
327
321
|
end
|
@@ -338,23 +332,43 @@
|
|
338
332
|
|
339
333
|
if range.weight(i).class == Float
|
340
334
|
|
335
|
+
printf("距離範囲重み: %f\n", range.weight(i))
|
336
|
+
|
341
337
|
weight += range.weight(i)
|
342
338
|
|
343
339
|
else
|
344
340
|
|
341
|
+
printf("距離範囲重み: ?\n")
|
342
|
+
|
345
343
|
q_flag = 1
|
346
344
|
|
347
345
|
end
|
348
346
|
|
349
347
|
end
|
350
348
|
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
if q_flag == 0
|
354
|
+
|
355
|
+
printf("重み合計: %f\n", weight)
|
356
|
+
|
357
|
+
else
|
358
|
+
|
359
|
+
printf("重み合計: ?\n")
|
360
|
+
|
361
|
+
end
|
362
|
+
|
363
|
+
|
364
|
+
|
351
365
|
write.count_car_or_human(weight,q_flag)
|
352
366
|
|
353
367
|
|
354
368
|
|
355
369
|
q_flag = 0
|
356
370
|
|
357
|
-
|
371
|
+
|
358
372
|
|
359
373
|
end
|
360
374
|
|
@@ -362,11 +376,7 @@
|
|
362
376
|
|
363
377
|
|
364
378
|
|
365
|
-
def output
|
379
|
+
def output
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
#write.count_ans
|
370
380
|
|
371
381
|
printf("\n---------------------result------------------------\n")
|
372
382
|
|
@@ -380,21 +390,23 @@
|
|
380
390
|
|
381
391
|
printf("\n---------------------------------------------------\n")
|
382
392
|
|
383
|
-
Result.create(:ishuman => count_human)
|
393
|
+
Result.create(:ishuman => write.count_human)
|
384
|
-
|
394
|
+
|
385
|
-
Result.create(:iscar => count_car)
|
395
|
+
Result.create(:iscar => write.count_car)
|
386
396
|
|
387
397
|
@resultvalue = Result.all
|
388
398
|
|
399
|
+
|
400
|
+
|
389
401
|
end
|
390
402
|
|
391
403
|
|
392
404
|
|
393
|
-
sta
|
405
|
+
class AddressController < ApplicationController
|
394
|
-
|
406
|
+
|
395
|
-
c
|
407
|
+
include Process
|
396
|
-
|
408
|
+
|
397
|
-
|
409
|
+
end
|
398
410
|
|
399
411
|
end
|
400
412
|
|
2
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,7 +92,23 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
+
@query = uri.query
|
96
|
+
|
97
|
+
puts "aaa"
|
98
|
+
|
99
|
+
# 新しくHTTPセッションを開始し、結果をresponseへ格納
|
100
|
+
|
101
|
+
response = Net::HTTP.start(uri.host,
|
102
|
+
|
103
|
+
use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
104
|
+
|
105
|
+
#response = https.start
|
106
|
+
|
95
|
-
|
107
|
+
# 接続時に待つ最大秒数を設定
|
108
|
+
|
109
|
+
open_timeout: 5
|
110
|
+
|
111
|
+
){|https| https.get(uri.request_uri)}
|
96
112
|
|
97
113
|
|
98
114
|
|
@@ -138,9 +154,39 @@
|
|
138
154
|
|
139
155
|
include Process
|
140
156
|
|
141
|
-
|
157
|
+
# 別のURLに飛ばされた場合
|
158
|
+
|
142
|
-
|
159
|
+
when Net::HTTPRedirection
|
160
|
+
|
161
|
+
@message = "Redirection: code=#{response.code} message=#{response.message}"
|
162
|
+
|
143
|
-
|
163
|
+
# その他エラー
|
164
|
+
|
165
|
+
else
|
166
|
+
|
167
|
+
@message = "HTTP ERROR: code=#{response.code} message=#{response.message}"
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
# エラー時処理
|
172
|
+
|
173
|
+
rescue IOError => e
|
174
|
+
|
175
|
+
@message = e.message
|
176
|
+
|
177
|
+
rescue TimeoutError => e
|
178
|
+
|
179
|
+
@message = e.message
|
180
|
+
|
181
|
+
rescue JSON::ParserError => e
|
182
|
+
|
183
|
+
@message = e.message
|
184
|
+
|
185
|
+
rescue => e
|
186
|
+
|
187
|
+
@message = e.message
|
188
|
+
|
189
|
+
end
|
144
190
|
|
145
191
|
end
|
146
192
|
|
1
文章の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,19 +14,31 @@
|
|
14
14
|
|
15
15
|
ActionView::Template::Error (undefined method `each' for nil:NilClass):
|
16
16
|
|
17
|
+
1: <head>
|
18
|
+
|
19
|
+
2: <meta http-equiv='refresh' content='10'>
|
20
|
+
|
21
|
+
3: </head>
|
22
|
+
|
23
|
+
4: <h1>IoT交通量調査</h1>
|
24
|
+
|
25
|
+
6: <p>
|
26
|
+
|
27
|
+
7: <% @value.each do |rawdate| %>
|
28
|
+
|
17
29
|
8: [distance] <%= rawdate.distance %>
|
18
30
|
|
19
|
-
|
31
|
+
8: [time] <%= rawdate.time %><br>
|
20
|
-
|
32
|
+
|
21
|
-
|
33
|
+
9: <% end %>
|
22
|
-
|
34
|
+
|
23
|
-
1
|
35
|
+
10: <% @resultvalue.each do |result| %>
|
24
|
-
|
36
|
+
|
25
|
-
1
|
37
|
+
11: [ishuman] <%= result.ishuman %>
|
26
|
-
|
38
|
+
|
27
|
-
1
|
39
|
+
12: [iscar] <%= result.iscar %>
|
28
|
-
|
40
|
+
|
29
|
-
1
|
41
|
+
13: <% end %>
|
30
42
|
|
31
43
|
|
32
44
|
|
@@ -48,7 +60,9 @@
|
|
48
60
|
|
49
61
|
### 調べた内容・試した内容
|
50
62
|
|
51
|
-
concern内のプログラムでresultテーブルにデータを入れたり、子クラスの中でrawdataテーブルからデータを取り出したりするプログラムを書きました。concern下のプログラムが動作してないと思われるためにviewでnomethoderrorが発生しています。
|
63
|
+
concern内のプログラムでresultテーブルにデータを入れたり、子クラスの中でrawdataテーブルからデータを取り出したりするプログラムを書きました。concern下のプログラムがcontroller内のinclude Processで動作してないと思われるためにviewでnomethoderrorが発生しています。
|
64
|
+
|
65
|
+
以下にcontrollerとconcern下に置かれているProcess.rbのプログラムを載せます。
|
52
66
|
|
53
67
|
### 該当のソースコード
|
54
68
|
|
@@ -136,7 +150,7 @@
|
|
136
150
|
|
137
151
|
|
138
152
|
|
139
|
-
```Proc
|
153
|
+
```Process
|
140
154
|
|
141
155
|
module Process
|
142
156
|
|