Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 5 with DelayedJob resulting in an error

I have installed Rails 5.0.0.rc1 as well as the DelayedJob gem. I have some code that worked perfectly fine in previous Rails apps (Rails4.2), but for some reason it keeps on failing in production on heroku now.

In short, I'm trying to send an email using DelayedJob's 'handle_asynchronously' method. I have created the mailer and added the callback in my model, but when I submit the form on Heroku, I am presented with a Rails error screen. In my logs, I am seeing an error stating 'ArgumentError: wrong number of arguments (given 1, expected 0)'. If I remove the 'handle_asynchronously' methods then my callbacks work. I obviously want to send mails etc. using DelayedJob however.

My code looks like this:

FooModel.rb

....
after_create    :send_welcome_mail
def send_welcome_mail
    FooMailer.welcome_email(self).deliver
end
handle_asynchronously :send_welcome_mail

Like I stated, this code worked flawlessly with Rails4. Could anybody help me? Do I need to do something differently in Rails5?

like image 712
HermannHH Avatar asked Jan 05 '23 23:01

HermannHH


1 Answers

It looks to me like Delayed Job does not support Rails 5 yet:

https://github.com/collectiveidea/delayed_job/issues/896

like image 107
Paul A Jungwirth Avatar answered Jan 15 '23 06:01

Paul A Jungwirth