Rails 3 - 结束第一个操作后可以运行一个操作吗?
我对在结束当前操作时立即运行操作的选项感兴趣。
更具体地说,我想运行一个操作来从我的页面下载文件,下载所有文件后该操作将结束(通常行为 - 该操作由 CRON 运行)。
现在我想自动运行第二个操作。此操作将检查下载的文件...
是否存在任何方式,怎么办? 非常感谢你,
M。
I am interesting about an option to run an action in a moment, when is ending the currently action.
More specifically, I want to run an action for download files from my page and after downloading all files this action is ending (usually behavior - this action is running by CRON).
And now I would like to automatically run the second action. This action will be checking the downloaded files...
Exist any way, how to do?
Thank you a lot,
M.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在一个请求中多次渲染。 HTTP 请求只能有一个响应,因此如果您这样做,最终会得到串联的输出,这可能没有用。
如果您有来自要调用的另一个操作(不包括渲染)的控制器逻辑,则可以通过简单地调用其他操作方法或将所需的逻辑分解到控制器上的单独方法中来完成此操作。如果您尝试在单独的控制器之间共享逻辑,则需要将此方法移至您的
ApplicationController
。You cannot render multiple times in one request. HTTP requests can only have one response, so if you did, you would end up with the output concatenated, which would probably not be useful.
If you have controller logic from another action that you want to invoke (which does not include rendering), you can do this by simply calling the other action method, or by factoring the logic you need into a separate method on the controller. If you were trying to share logic among separate controllers, you would need to move this method to your
ApplicationController
.