Skip to content

Commit

Permalink
Use deliver_now in Rails 4.2+, fixes sidekiq#1933
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Sep 28, 2014
1 parent 3dad3f1 commit 8c5b24a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/sidekiq/extensions/action_mailer.rb
Expand Up @@ -17,7 +17,19 @@ def perform(yml)
msg = target.public_send(method_name, *args)
# The email method can return nil, which causes ActionMailer to return
# an undeliverable empty message.
msg.deliver if msg && (msg.to || msg.cc || msg.bcc) && msg.from
deliver(msg) if msg && (msg.to || msg.cc || msg.bcc) && msg.from
end

private

def deliver(msg)
if msg.respond_to?(:deliver_now)
# Rails 4.2/5.0
msg.deliver_now
else
# Rails 3.2/4.0/4.1
msg.deliver
end
end
end

Expand Down

0 comments on commit 8c5b24a

Please sign in to comment.