Rails 3 - Delayed_Job (collectidea), attempt by Delay Mailers - Error: NoMethodError (undefined `delay 'method for UserMailer: Class)

I use delayed_job gem here: https://github.com/collectiveidea/delayed_job

In an observer, I have the following:

UserMailer.delay.msg_notification(record) 

In user_mailer.rb

 class UserMailer < ActionMailer::Base ... def msg_notification(record) mail( :to => "#{record.user.email}", :subject => "Notification" ) end .. end 

But these errors are with:

  NoMethodError (undefined method `delay' for UserMailer:Class): 

Any ideas? thanks

+6
ruby-on-rails ruby-on-rails-3 delayed-job
source share
2 answers

I saw such a problem in our Rails application (2.3.8, but the problem sounds the same). Basically, there are three ways to delay an action:

  • MyClass.delay.foo(arg)
  • Put handle_asynchronously :foo in your class definition after defining foo
  • MyClass.send_later(:foo, arg)

For some reason, No. 3 was the only form that consistently worked on all of our development machines. # 1 died on our development server (Ubuntu); # 2 on our Mac designer. But number 3 was good.

Hope this helps!

+4
source share

Also check if you rebooted the server after installing the package. This may also be a problem ...

+2
source share

All Articles