質問編集履歴

8

誤記修正

2019/07/16 05:20

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -96,9 +96,9 @@
96
96
 
97
97
  end
98
98
 
99
+ line += 1
100
+
99
101
  end
100
-
101
- line += 1
102
102
 
103
103
  end
104
104
 

7

modelでの@statusesへの詰め込み方法を修正

2019/07/16 05:20

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -88,11 +88,7 @@
88
88
 
89
89
  if row[…] ※判断文(省略)
90
90
 
91
- row["error_reason"] = "E001"
92
-
93
- row["line"] = line
94
-
95
- @statuses << { "row" => row }
91
+ @statuses << { "error_reason" => "E002", "line" => line, "row" => row }
96
92
 
97
93
  error_cnt += 1
98
94
 

6

誤記修正

2019/07/16 04:55

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -150,7 +150,7 @@
150
150
 
151
151
  td =status["error_reason"]
152
152
 
153
- td =status["tool_setup_number"]
153
+ td =status["number"]
154
154
 
155
155
  td =status["generation"]
156
156
 

5

誤記修正

2019/07/16 04:39

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -78,9 +78,9 @@
78
78
 
79
79
  error_reason = ""
80
80
 
81
- @tool_setup_statuses = []
81
+ @statuses = []
82
82
 
83
- @tool_lists = []
83
+ @lists = []
84
84
 
85
85
 
86
86
 

4

体裁修正

2019/07/16 04:38

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -40,7 +40,7 @@
40
40
 
41
41
  flash.now[:alert] = "Import result to tool_list<br/>
42
42
 
43
- ---> Import_error = #{error_cnt.to_s}".html_safe
43
+          ---> Import_error = #{error_cnt.to_s}".html_safe
44
44
 
45
45
  render template: "statuses/import_result", collection: @statuses
46
46
 
@@ -48,9 +48,9 @@
48
48
 
49
49
  flash.now[:notice] = "Import result to tool_list<br/>
50
50
 
51
- ---> Added = #{add_cnt.to_s}<br/>
51
+             ---> Added = #{add_cnt.to_s}<br/>
52
52
 
53
- ---> Updated = #{update_cnt.to_s}".html_safe
53
+      ---> Updated = #{update_cnt.to_s}".html_safe
54
54
 
55
55
  redirect_to lists_path
56
56
 
@@ -90,13 +90,13 @@
90
90
 
91
91
  row["error_reason"] = "E001"
92
92
 
93
- row["line"] = line
93
+ row["line"] = line
94
94
 
95
- @statuses << { "row" => row }
95
+ @statuses << { "row" => row }
96
96
 
97
- error_cnt += 1
97
+ error_cnt += 1
98
98
 
99
- next
99
+ next
100
100
 
101
101
  end
102
102
 
@@ -148,10 +148,12 @@
148
148
 
149
149
  td =status["line"]
150
150
 
151
- td =status["error_reason"]
151
+ td =status["error_reason"]
152
152
 
153
- td =status["tool_setup_number"]
153
+ td =status["tool_setup_number"]
154
154
 
155
- td =status["generation"]
155
+ td =status["generation"]
156
156
 
157
157
  end
158
+
159
+ ```

3

view追加、controller & model 最新情報に更新

2019/07/16 03:47

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -34,23 +34,23 @@
34
34
 
35
35
  else
36
36
 
37
- add_cnt, update_cnt, error_cnt, @obj_import_result = List.tss_import(params[:file])
37
+ add_cnt, update_cnt, error_cnt, @statuses = List.tss_import(params[:file])
38
38
 
39
39
  if error_cnt > 0 then
40
40
 
41
- flash[:alert] = "Import result to list<br/>
41
+ flash.now[:alert] = "Import result to tool_list<br/>
42
42
 
43
- ---> Import_error = #{error_cnt.to_s}".html_safe
43
+ ---> Import_error = #{error_cnt.to_s}".html_safe
44
44
 
45
- render template: "statuses/import_result", object: @obj_import_result
45
+ render template: "statuses/import_result", collection: @statuses
46
46
 
47
47
  else
48
48
 
49
- flash[:notice] = "Import result to list<br/>
49
+ flash.now[:notice] = "Import result to tool_list<br/>
50
50
 
51
- ---> Added = #{add_cnt.to_s}<br/>
51
+ ---> Added = #{add_cnt.to_s}<br/>
52
52
 
53
- ---> Updated = #{update_cnt.to_s}".html_safe
53
+ ---> Updated = #{update_cnt.to_s}".html_safe
54
54
 
55
55
  redirect_to lists_path
56
56
 
@@ -68,17 +68,47 @@
68
68
 
69
69
  def self.tss_import(file)
70
70
 
71
+ add_cnt = 0
72
+
73
+ update_cnt = 0
74
+
75
+ error_cnt = 0
76
+
77
+ line = 1
78
+
79
+ error_reason = ""
80
+
81
+ @tool_setup_statuses = []
82
+
83
+ @tool_lists = []
84
+
85
+
86
+
71
87
  CSV.foreach(file.path, headers: true, encoding: 'Shift_JIS:UTF-8') do |row|
72
88
 
73
89
  if row[…] ※判断文(省略)
74
90
 
75
- #不整合と判断
91
+ row["error_reason"] = "E001"
76
92
 
93
+ row["line"] = line
94
+
77
- @statuses = row ※オブジェクトに追加するコーディングが分かりません。
95
+ @statuses << { "row" => row }
96
+
97
+ error_cnt += 1
98
+
99
+ next
78
100
 
79
101
  end
80
102
 
81
103
  end
104
+
105
+ line += 1
106
+
107
+ end
108
+
109
+
110
+
111
+ if error_cnt > 0
82
112
 
83
113
  return add_cnt, update_cnt, error_cnt, @statuses
84
114
 
@@ -87,3 +117,41 @@
87
117
 
88
118
 
89
119
  ```
120
+
121
+ view
122
+
123
+ ```ここに言語名を入力
124
+
125
+ h1 Status import result
126
+
127
+
128
+
129
+ table
130
+
131
+ thead
132
+
133
+ tr
134
+
135
+ th line
136
+
137
+ th error_reason
138
+
139
+ th number
140
+
141
+ th generation
142
+
143
+ tbody
144
+
145
+ - @statuses.each do |status|
146
+
147
+ tr
148
+
149
+ td =status["line"]
150
+
151
+ td =status["error_reason"]
152
+
153
+ td =status["tool_setup_number"]
154
+
155
+ td =status["generation"]
156
+
157
+ end

2

model->controllerに渡す情報を追加、controller側で受け取った後のerror_cnt判断追加

2019/07/16 03:45

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
@@ -34,11 +34,29 @@
34
34
 
35
35
  else
36
36
 
37
- @statuses = List.tss_import(params[:file])
37
+ add_cnt, update_cnt, error_cnt, @obj_import_result = List.tss_import(params[:file])
38
38
 
39
- render template: "statuses/import_result", object: @statuses
39
+ if error_cnt > 0 then
40
40
 
41
+ flash[:alert] = "Import result to list<br/>
42
+
43
+ ---> Import_error = #{error_cnt.to_s}".html_safe
44
+
45
+ render template: "statuses/import_result", object: @obj_import_result
46
+
47
+ else
48
+
49
+ flash[:notice] = "Import result to list<br/>
50
+
51
+ ---> Added = #{add_cnt.to_s}<br/>
52
+
53
+ ---> Updated = #{update_cnt.to_s}".html_safe
54
+
55
+ redirect_to lists_path
56
+
41
- end
57
+ end
58
+
59
+ end
42
60
 
43
61
  end
44
62
 
@@ -62,7 +80,7 @@
62
80
 
63
81
  end
64
82
 
65
- @statuses
83
+ return add_cnt, update_cnt, error_cnt, @statuses
66
84
 
67
85
  end
68
86
 

1

2019/07/11 00:35

投稿

Amkys
Amkys

スコア17

test CHANGED
File without changes
test CHANGED
File without changes