Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User.import_csv(params[:file].path)
- CsvImportJob.perform_async(URI.parse(params[:file].path))
- def perform(file_path)
- User.import_csv(file_path)
- end
- » 10 Aug 2015 13:56:26.596 2015-08-10 11:56:25.987726+00:00 app worker.1 - - 3 TID-oqvt6v1d4 ERROR: Actor crashed!
- » 10 Aug 2015 13:56:26.596 2015-08-10 11:56:25.987728+00:00 app worker.1 - - Errno::ENOENT: No such file or directory @ rb_sysopen - /tmp/RackMultipart20150810-6-14u804c.csv
- » 10 Aug 2015 13:56:26.596 2015-08-10 11:56:25.987730+00:00 app worker.1 - - /app/vendor/ruby-2.2.2/lib/ruby/2.2.0/csv.rb:1256:in `initialize'
- require 'open-uri'
- class ProcessCsvJob < ActiveJob::Base
- queue_as :default
- def perform(csv_path)
- csv_file = open(csv_path,'rb:UTF-8')
- SmarterCSV.process(csv_file) do |array|
- .... code here for processing ...
- end
- end
- end
- def import_csv(file)
- CSV.foreach(file.path, headers: true) do |row|
- new_user = { email: row[0], password: row[1] }
- CsvImportJob.perform_async(new_user)
- end
- end
Add Comment
Please, Sign In to add comment