Search code examples
ruby-on-railsresque

RoR, resque, JSON::GeneratorError


I use Rails 4.1.6 I try started resque worker but I get error:

JSON::GeneratorError in BookRelationsController#import_books
partial character in source, but hit end

My code:

file = 'public/file.xlsx'
Resque.enqueue(ProcessImportJob, File.new(file))

How fix this error? Thank


Solution

  • You cannot pass File object as an argument to Resque. You can pass only those arguments, that can be parsed to JSON

    Resque.enqueue(ProcessImportJob, 'public/file.xlsx')

    Then in your worker process you open the file using the passed filename.