activerecord_csv_importer 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1a505ce5dfd1cb65fed9b65f5cd77e09a8d905
|
4
|
+
data.tar.gz: 0c04ae7e26d2cc0b96e615d5561ea11aa23e823a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c4a4cca5c6a5135f5535cf9399e89d0c18342240bc22ce5936a2bd0d77fb37b853555ed54d5aaecee9392672c8aefce1101ff20392b2c337a3bbabed6489f59
|
7
|
+
data.tar.gz: a72973e303bb5312d272b3331719238e19e543e1559fe9cd2b9864c6915081693b5fe3833e17eece818bfbd9cd2062fcf25e0d97163d0eca61c60b34020ad527
|
@@ -42,6 +42,10 @@ module ActiveRecordCSVImporter
|
|
42
42
|
(column_definitions - columns.map(&:definition)).map(&:name).map(&:to_s)
|
43
43
|
end
|
44
44
|
|
45
|
+
def column_definition_names
|
46
|
+
column_definitions.map(&:name).map(&:to_s)
|
47
|
+
end
|
48
|
+
|
45
49
|
private
|
46
50
|
|
47
51
|
def find_column_definition(name)
|
@@ -49,9 +53,5 @@ module ActiveRecordCSVImporter
|
|
49
53
|
column_definition.match?(name)
|
50
54
|
}
|
51
55
|
end
|
52
|
-
|
53
|
-
def column_definition_names
|
54
|
-
column_definitions.map(&:name).map(&:to_s)
|
55
|
-
end
|
56
56
|
end
|
57
57
|
end
|
@@ -38,7 +38,7 @@ module ActiveRecordCSVImporter
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def import_rows(set)
|
41
|
-
config.model.import(header.
|
41
|
+
config.model.import(header.column_definition_names.dup, set, config.on_duplicate_key)
|
42
42
|
end
|
43
43
|
|
44
44
|
def add_to_report(response, set)
|
@@ -50,7 +50,7 @@ module ActiveRecordCSVImporter
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def columns_for(model)
|
53
|
-
model.attributes.values_at(*header.
|
53
|
+
model.attributes.values_at(*header.column_definition_names)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Error from the model mapped back to the CSV header if we can
|