Я пытаюсь переместить текущую рабочую задачу (в производстве и в консоли), чтобы использовать delayed_job в приложении Rails 2, но продолжаю получать сообщение об ошибке:
ThermalImageJob failed with NameError: uninitialized constant Barby::Code128B
Я просматривал чужой код в поисках ответа, но безрезультатно. Вот мой код:
/lib/thermal_image_job.rb
class ThermalImageJob < Struct.new(:order_id)
def perform
order = Order.find(order_id)
order.tickets.each do |ticket|
ticket.barcodes.each do |barcode|
barcode.generate_thermal_image
end
end
end
end
/приложение/контроллеры/orders_controller.rb
Delayed::Job.enqueue(ThermalImageJob.new(@order.id))
/приложение/модели/barcode.rb
def generate_thermal_image(format=:gif)
filename = "#{barcode}_thermal.#{format}"
temp_file_path = File.join("#{RAILS_ROOT}", 'tmp', filename)
unless FileTest.exists?(temp_file_path)
barcode_file = File.new(temp_file_path, 'w')
code = Barby::Code128B.new(barcode)
....
end
Gemfile
gem "delayed_job", "2.0.7"
gem "daemons", "1.0.10"