How should I be using delayed_job?

試著忘記壹切 提交于 2019-12-12 06:32:38

问题


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 generated title returned from the Embedly API into my database so users can edit it later.


回答1:


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.



来源:https://stackoverflow.com/questions/5320548/how-should-i-be-using-delayed-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!