Skip to content

Instantly share code, notes, and snippets.

@maxschmeling
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxschmeling/325d712b6652a9bf79a9 to your computer and use it in GitHub Desktop.
Save maxschmeling/325d712b6652a9bf79a9 to your computer and use it in GitHub Desktop.
CallbackWorker
class CallbackWorker
include Sidekiq::Worker
def perform(global_id, method, *params)
model = GlobalID::Locator.locate(global_id)
model.send method, *params
end
end
class Customer < ActiveRecord::Base
after_create do
CallbackWorker.perform_async self.to_global_id, :send_to_slack
end
def send_to_slack
# ... code to send notice to Slack channel
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment