NoMethodError when trying to delay a mailer

188 views
Skip to first unread message

Marc

unread,
Jun 9, 2011, 12:36:30 PM6/9/11
to delayed_job
Hi all,

I am having some trouble with delaying a mailer using delayed_job.

I call the mailer from the controller thusly:

UserMailer.delay.standard_message(user, email)

The UserMailer class looks like this:

class UserMailer < ActionMailer::Base
include ActionView::Helpers::NumberHelper

default :from => "'Safrea' <ad...@safrea.co.za>"

def standard_message(user, email)
@content = replace_tokens(email.body, user)
mail(:to => user.email, :subject => email.subject)
end

def replace_tokens(body, user)
<snipped>
end
end

Inspecting the delayed_job table, this is found in the handler field:

--- !ruby/struct:Delayed::PerformableMailer
object: !ruby/object:Class UserMailer
method_name: :standard_message
args:
- !ruby/object:User
attributes:
id: <id here>
email: <email address here>
<SNIP>
- !ruby/object:Email
attributes:
id: <id here>
subject: <subject here>
body: <SNIP>


The emails are not delivered, and I am left with the following error:

Class#standard_message failed with NoMethodError: undefined method
`standard_message' for #<Class:0xc4d360c>

Any help or pointers would be appreciated!

Thanks,
Marc

Ricardo Bernardelli

unread,
Jun 9, 2011, 3:34:14 PM6/9/11
to delay...@googlegroups.com
Hey Marc!

what server are you using?
this is a kind of serialization issue.
instead of object: !ruby/object:UserMailer, delayed job saves object: !ruby/object:Class UserMailer.
when it works off, Class.your_method doesnt exist.

there's a known error that u can see here: https://github.com/collectiveidea/delayed_job/wiki/Common-problems

hope it helps!

Ricardo
--
the sun shines for all

http://rbernardelli.com
http://twitter.com/rbernardelli
http://github.com/bernardelli

Marc

unread,
Jun 9, 2011, 4:15:11 PM6/9/11
to delayed_job
Thanks for the reply Ricardo.

It definitely looks like I am having this "serialization" error, but I
am using Apache/Passenger, not thin, so I'm not too sure what to look
into now.

- Marc

On Jun 9, 9:34 pm, Ricardo Bernardelli <ricardo...@gmail.com> wrote:
> Hey Marc!
>
> what server are you using?
> this is a kind of serialization issue.
> instead of object: !ruby/object:UserMailer, delayed job saves object:
> !ruby/object:*Class* UserMailer.
> when it works off, Class.your_method doesnt exist.
>
> there's a known error that u can see here:https://github.com/collectiveidea/delayed_job/wiki/Common-problems
>
> hope it helps!
>
> Ricardo
>

Marc

unread,
Jun 12, 2011, 8:06:14 AM6/12/11
to delayed_job
This is really killing me.

When I call the job from the application, it breaks, but if I run it
from the console using bundle exec rails c, it works fine - with the
same environment loaded in both cases. Any ideas what the difference
could be between the two that causes the one to break, and the other
to work?

- Marc
> >http://rbernardelli.comhttp://twitter.com/rbernardellihttp://github.c...

Marc

unread,
Jun 12, 2011, 9:56:14 AM6/12/11
to delayed_job
I have it sorted.

I created a setup_load_paths.rb a few weeks ago (for reasons I can't
remember), and since it prevented the loading of the Gemfile, it
mucked up the call to YAML::ENGINE.yamler = "syck".

I removed setup_load_paths.rb and everything is working well again.

- Marc

Ricardo Bernardelli

unread,
Jun 12, 2011, 3:56:45 PM6/12/11
to delay...@googlegroups.com
Great, Marc!
Reply all
Reply to author
Forward
0 new messages