My controller data_files_controller.rb
def upload_balances
DataFile.load_balances(params)
end
My model data_file.rb def self.load_balances(params)
# Pull the file out of the http request, write it to file system
name = params['Filename']
directory = "public/uploads"
errors_table_name = "snapshot_errors"
upload_file = File.join(directory, name)
File.open(upload_file, "wb") { |f| f.write(params['Filedata'].read) }
# Remove the old data from the table
Balance.destroy_all
------ more code-----
end
It's working fine. Now i want to use delayed job with my controller to call my model action like .. My controller data_files_controller.rb
def upload_balances
DataFile.send_later(:load_balances,params)
end
Is it possible?? What's the other way to do it? Is it create any problem?
With this send_later i am getting this error in column last_error in delayed_job table.
uninitialized stream
C:/cyncabc/app/models/data_file.rb:12:in read'
C:/cyncabc/app/models/data_file.rb:12:in
load_balances'
C:/cyncabc/app/models/data_file.rb:12:in `open'
I am getting error on line
File.open(upload_file, "wb") { |f| f.write(params['Filedata'].read) }
while reading params['Filedata'].read.
how to check i am getting proper data in params['Filedata'] or not ? Without send_later it's working fine... Is there any solution?