开发者

How should I be using delayed_job?

I've read the docs, but I'm unsure how to integrate it into my application. Currently I have a user input a video url, I take that url and make it a link in the view. Then I use the Embedly API to find that link and replace it with an embedded video, thumbnail, and title. However, this process takes a bit too long, so I'm thinking of using delayed_job to speed up this process. How should I go about doing this? I'd like to also save the dynamically generate开发者_开发知识库d title returned from the Embedly API into my database so users can edit it later.


DJ jobs can be anything. Did you read the DJ tutorial? If you have a Video model, use an after_save callback that calls a function, say, generate_video_widget(), via DJ, like so:

self.delay.generate_video_widget()

It's up to you to implement generate_video_widget() to do the things you need it to do.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜