Skip to content

Instantly share code, notes, and snippets.

@nandokakimoto
Created March 27, 2017 01:17
Show Gist options
  • Save nandokakimoto/85ef460f08dd2083de0917686c9daade to your computer and use it in GitHub Desktop.
Save nandokakimoto/85ef460f08dd2083de0917686c9daade to your computer and use it in GitHub Desktop.
Simple Active Job example
class BillingService
def self.process(order)
Rails.logger.info "Processing order #{order.id}..."
sleep(3)
Rails.logger.info "Order #{order.id} processed successfully."
end
end
require './app/services/billing_service'
class ProcessOrderJob < ApplicationJob
queue_as :default
def perform(order_id)
order = Order.find(order_id)
BillingService.process(order)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment