質問編集履歴
7
model
test
CHANGED
File without changes
|
test
CHANGED
@@ -150,11 +150,11 @@
|
|
150
150
|
|
151
151
|
row = Hash[[header, spreadsheet.row(i)].transpose]
|
152
152
|
|
153
|
-
|
153
|
+
btob_quotation = find_by_id(row["id"]) || new
|
154
154
|
|
155
|
-
|
155
|
+
btob_quotation.attributes = row.to_hash.slice(*accessible_attributes)
|
156
156
|
|
157
|
-
|
157
|
+
btob_quotation.save!
|
158
158
|
|
159
159
|
end
|
160
160
|
|
@@ -166,7 +166,7 @@
|
|
166
166
|
|
167
167
|
case File.extname(file.original_filename)
|
168
168
|
|
169
|
-
when ".csv" then C
|
169
|
+
when ".csv" then CSV.new(file.path, nil)
|
170
170
|
|
171
171
|
else raise "Unknown file type: #{file.original_filename}"
|
172
172
|
|
6
.
test
CHANGED
File without changes
|
test
CHANGED
@@ -178,11 +178,9 @@
|
|
178
178
|
|
179
179
|
|
180
180
|
|
181
|
-
###
|
181
|
+
### 参考にしているサイト
|
182
182
|
|
183
183
|
|
184
|
-
|
185
|
-
参考にしているサイト
|
186
184
|
|
187
185
|
[#396 Importing CSV and Excel – RailsCasts](http://railscasts.com/episodes/396-importing-csv-and-excel?autoplay=true)
|
188
186
|
|
5
im
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,7 +24,11 @@
|
|
24
24
|
|
25
25
|
エラー画面キャプチャ
|
26
26
|
|
27
|
-
![イメージ説明](
|
27
|
+
![イメージ説明](40b0ca0abc0d113b4c6e5b3b3fade122.png)
|
28
|
+
|
29
|
+
![イメージ説明](5273177b8d9ed1d00c42aab3da3953ff.png)
|
30
|
+
|
31
|
+
![イメージ説明](5090853f50a90391d057f522f89391fa.png)
|
28
32
|
|
29
33
|
|
30
34
|
|
4
log
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,6 +25,48 @@
|
|
25
25
|
エラー画面キャプチャ
|
26
26
|
|
27
27
|
![イメージ説明](2278aaa009969b05d8405e3d01dd6d40.png)
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
CSVファイルをアップロードした際のログ
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
I, [2019-07-17T18:26:15.712452 #9546] INFO -- : Started POST "/btob_quotations/import" for 192.168.11.30 at 2019-07-17 18:26:15 +0900
|
36
|
+
|
37
|
+
I, [2019-07-17T18:26:15.714922 #9546] INFO -- : Cannot render console from 192.168.11.30! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
|
38
|
+
|
39
|
+
I, [2019-07-17T18:26:15.771705 #9546] INFO -- : Processing by BtobQuotationsController#import as HTML
|
40
|
+
|
41
|
+
I, [2019-07-17T18:26:15.772242 #9546] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"7PtnpymZqYBn4UOP7OTDiVCi6ZhKZ0WZ8UhM8lzk/DPUqdXybcW6bN+tq/8AatqqK6yK+eUGrk8Qj20wKRd2jA==", "file"=>#<ActionDispatch::Http::UploadedFile:0x00007f433e909f10 @tempfile=#<Tempfile:/tmp/RackMultipart20190717-9546-1tgkswu.csv>, @original_filename="btob_quotations (2).csv", @content_type="application/vnd.ms-excel", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"btob_quotations (2).csv\"\r\nContent-Type: application/vnd.ms-excel\r\n">, "commit"=>"オブジェクトを一括インポート"}
|
42
|
+
|
43
|
+
D, [2019-07-17T18:26:15.774000 #9546] DEBUG -- : ActiveRecord::SessionStore::Session Load (0.4ms) SELECT `sessions`.* FROM `sessions` WHERE `sessions`.`session_id` = 'cf79cf20b72b18e45fb13cb190223dc2' ORDER BY `sessions`.`id` ASC LIMIT 1
|
44
|
+
|
45
|
+
I, [2019-07-17T18:26:15.786085 #9546] INFO -- : Completed 500 Internal Server Error in 13ms (ActiveRecord: 0.4ms)
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
F, [2019-07-17T18:26:15.825356 #9546] FATAL -- :
|
52
|
+
|
53
|
+
NameError - uninitialized constant BtobQuotation::Csv:
|
54
|
+
|
55
|
+
app/models/btob_quotation.rb:34:in `open_spreadsheet'
|
56
|
+
|
57
|
+
app/models/btob_quotation.rb:22:in `import'
|
58
|
+
|
59
|
+
app/controllers/btob_quotations_controller.rb:86:in `import'
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
I, [2019-07-17T18:26:15.928236 #9546] INFO -- : Started POST "/__better_errors/5de3351b5bd4fa51/variables" for 192.168.11.30 at 2019-07-17 18:26:15 +0900
|
64
|
+
|
65
|
+
I, [2019-07-17T18:26:15.929145 #9546] INFO -- : Cannot render console from 192.168.11.30! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```
|
28
70
|
|
29
71
|
|
30
72
|
|
3
あ
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Ruby on RailsでCSVファイルインポート
|
1
|
+
Ruby on RailsでCSVファイルインポートがエラーになる。
|
test
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
タブ区切りCSVファイルからのインポートがうまくいかない。
|
6
|
+
|
7
|
+
CSVファイルをアップロードすると下記のエラーになる。
|
6
8
|
|
7
9
|
検索しても情報が少なく、自力で解決できそうにない。
|
8
10
|
|
2
.
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,7 +92,7 @@
|
|
92
92
|
|
93
93
|
```
|
94
94
|
|
95
|
-
def self.import(file)
|
95
|
+
def self.import(file)
|
96
96
|
|
97
97
|
spreadsheet = open_spreadsheet(file)
|
98
98
|
|
1
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
CSVファイルからのインポートがうまくいかない。
|
5
|
+
タブ区切りCSVファイルからのインポートがうまくいかない。
|
6
6
|
|
7
7
|
検索しても情報が少なく、自力で解決できそうにない。
|
8
8
|
|