Rails 状态的后台作业
嘿。我想上传一个文件,然后解析它。因为解析可能需要长达10分钟,所以我安装了delayed_job插件并通过send_later函数调用解析函数。我不得不提的是,这是一个 AJAX 应用程序。
想象一下,您按下 AJAX 按钮开始上传,然后将源导入到数据库中。在此过程中,我想显示进度条或消息(正在导入...),并且当它完成时,任务状态更改为完成。
我的问题是:检查流程状态的最佳方法是什么?你会怎么办?我的想法是让另一个控制器操作“状态”,它查看数据库并提供正确的状态。
Hey. I would like to upload a file and then parse it. Because parsing can take up to 10min I installed delayed_job plugin and called parsing function through send_later function. I have to mention that this is an AJAX app.
Imagine that you press an AJAX button that starts upload and after that the source is imported into the database. During the process I want to show the progress bar or message (importing...) and when it completes the task status changes to done.
My question is: What is the best way to check for status of the process. What would you do? My idea is to have another controller actions "status" which look into the database and provide the right status.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我做了一个 Rails 插件,因为我遇到了和你一样的问题。它自动执行大部分代码来管理浏览器的后台任务(检查状态等)。
在这里查看:http://github.com/chrismoos/ajaxtask
工作原理:http://chrismoos.com/2010 /02/09/ajaxtask-a-rails-plugin-for-managing-background-tasks/
I made a plugin for rails because I had the same problem as you. It automates most of the code to manage a background task from the browser (check status, etc,.).
Check it out here: http://github.com/chrismoos/ajaxtask
How it works: http://chrismoos.com/2010/02/09/ajaxtask-a-rails-plugin-for-managing-background-tasks/
对我来说这是个好方法。
For me it's the good way.