csv_importable 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/lib/csv_importable/type_parser/select_type_parser.rb +1 -1
- data/lib/csv_importable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b24ce628fef6200d22e2a893af528412aa0bd770
|
4
|
+
data.tar.gz: 192aedab823e106a0e75e22469a11797ab129b54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2436754123fed4d793391e4acd6323fc871370288ff233fa79489e574a7bd4deb44cd3c3aae300860343a81558d9d270136df89fd9a6b50eefe92360b06b321f
|
7
|
+
data.tar.gz: 8cdb9d8a0d3d14e9bd412794444e52daa6cc6798863901e0ba52eca02a0353d6cebe5aed2ab9142864eab5fcdd1d532f52c7d863ba872b68aa030773426a4707
|
data/README.md
CHANGED
@@ -62,7 +62,16 @@ class Import < ApplicationRecord
|
|
62
62
|
include CSVImportable::Importable
|
63
63
|
|
64
64
|
has_attached_file :file
|
65
|
-
validates_attachment :file,
|
65
|
+
validates_attachment :file,
|
66
|
+
content_type: {
|
67
|
+
content_type: [
|
68
|
+
'text/plain',
|
69
|
+
'text/csv',
|
70
|
+
'application/vnd.ms-excel',
|
71
|
+
'application/octet-stream'
|
72
|
+
]
|
73
|
+
},
|
74
|
+
message: "is not in CSV format"
|
66
75
|
|
67
76
|
validates :file, presence: true
|
68
77
|
|
@@ -96,6 +105,14 @@ class Import < ApplicationRecord
|
|
96
105
|
end
|
97
106
|
```
|
98
107
|
|
108
|
+
And create a new file at config/initializers/paperclip.rb:
|
109
|
+
|
110
|
+
```
|
111
|
+
Paperclip.options[:content_type_mappings] = {
|
112
|
+
csv: ['application/vnd.ms-excel', 'application/octet-stream', 'text/csv', 'text/plain', 'text/comma-separated-values']
|
113
|
+
}
|
114
|
+
```
|
115
|
+
|
99
116
|
And then create a subclass that should correspond to the specific importing task you are implementing. For example, if you are trying to import users from a CSV, you might implement a `UserImport` class which inherits from `Import`:
|
100
117
|
|
101
118
|
app/models/user_import.rb:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csv_importable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Francis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|