开发者

Rails - Make MailChimp Hominid Gem, a background task

I'm trying to make my Hominid call to MailChimp API, however without much success. My call looks like

h.list_subscribe(:user_list_id, params[:email], {'FNAME' => '', 'LNAME' => ''}, 'html', true, true, true, false)

where h is an object of Homind::API class. This object neither has a 'delay' method provided by delayed_job gem. It does not even have standard methods like 'class' or 'methods'. When, I create a custom job, it is not added to the job queue.

Explicity, setting the method to 'handle_asynchronously' results in a

can't convert nil into String

in

lib/delayed/yaml_ext.r开发者_StackOverflowb:16:in `value='

I'm guessing Delayed_Job cannot serialize the very stripped own Hominid::API object. Suggestions on how to go about this are most welcome. Thanks!


Ah, the answer was there all along.

When a custom job is created, it needs to loaded from a initializer so that it is available when delayed_job executes the job. A simple,

require 'my_custom_job_class'

in any of the initializers will do.

You can also find more info from delayed_job wiki

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜