Skip to content

Instantly share code, notes, and snippets.

@manoelneto
Created August 9, 2018 12:30
Show Gist options
  • Save manoelneto/9d47156286bf23d9c701e10824fd5948 to your computer and use it in GitHub Desktop.
Save manoelneto/9d47156286bf23d9c701e10824fd5948 to your computer and use it in GitHub Desktop.
# Controller
SendEmailToUser.perform_async user.id
# ...
class SendEmailToUser
include Sidekiq::Worker
sidekiq_options :queue => :default, :retry => true, :backtrace => true
def perform user_id
begin
user = User.find user_id
rescue ActiveRecord::DocumentNotFound => e
logger.warn "User não existe, ignorando"
return
end
Mailer.send_mail_user(user).deliver
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment