handle_asynchronously

41 views
Skip to first unread message

Scott Johnson

unread,
Oct 29, 2009, 3:23:55 PM10/29/09
to delayed_job
I'm using the collectiveidea fork and trying to use
handle_asynchronously so that I can use DelayedJob only in my
production environment.

I have a SubscriptionObserver that sends email to all subscribers when
a new comment is left on my blog.

I'm testing this in development; in development.rb I set:

config.cache_classes = true
config.after_initialize do
SubscriptionObserver.handle_asynchronously :email_all_subscribers
end

But when I call email_all_subscribers, I get an exception:

NoMethodError (undefined method
`email_all_subscribers_without_send_later' for #<struct
Delayed::PerformableMethod object=nil, method=nil, args=nil>):
app/models/subscription_observer.rb:18:in `email_all_subscribers'
app/models/subscription_observer.rb:18:in `after_create'
/usr/lib/ruby/1.8/observer.rb:185:in `notify_observers'
/usr/lib/ruby/1.8/observer.rb:184:in `each'
/usr/lib/ruby/1.8/observer.rb:184:in `notify_observers'
app/controllers/comments_controller.rb:25:in `create'

I don't understand why it seems to be looking in
Delayed::PerformableMethod instead of SubscriptionObserver for this
method.

Scott Johnson

unread,
Oct 29, 2009, 3:35:22 PM10/29/09
to delayed_job
Hmm... seems to be that the error message itself is also in error
(line 7 of performable_method should have object.inspect, not
self.inspect).

So it is indeed looking in SubscriptionObserver, but for some reason
respond_to?(:email_all_subscribers_without_send_later) is false.

Scott Johnson

unread,
Oct 29, 2009, 7:31:27 PM10/29/09
to delayed_job
I commented out the error checking (line 7 of performable_method) and
everything is working fine.
Reply all
Reply to author
Forward
0 new messages