Class: ActAsImportable::CSVImporter
- Defined in:
- lib/act_as_importable/csv_importer.rb
Instance Method Summary collapse
Methods inherited from Importer
#delete_missing_records, #existing_record_ids, #existing_record_scope, #failed_imports, #filter_columns, #import_data, #import_record, #imported_records, #initialize, #missing_uid_values, #model_class, #options, #record_ids_to_delete, #successful_imports
Constructor Details
This class inherits a constructor from ActAsImportable::Importer
Instance Method Details
#import_csv_file(file) ⇒ Object
6 7 8 |
# File 'lib/act_as_importable/csv_importer.rb', line 6 def import_csv_file(file) import_csv_text(File.read(file, )) end |
#import_csv_text(text) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/act_as_importable/csv_importer.rb', line 10 def import_csv_text(text) csv = ::CSV.parse(text, :headers => [:headers] || true) csv.each do |row| import_record(row.to_hash) end end |