gpt4 book ai didi

ruby-on-rails - 如何在本地将所有 'perform_later' s 转换为 'perform_now' s?

转载 作者:行者123 更新时间:2023-12-04 16:33:27 24 4
gpt4 key购买 nike

我正在开发一种产品,该产品调用 perform_later工作。这适用于我们生产中的产品,因为我们有一系列的 worker 来运行所有的工作。

但是,当我在本地使用该应用程序时,我无法访问这些工作人员,我想更改所有 perform_later s 进入 perform_now s 仅当我在本地使用该应用程序时。

做到这一点的最佳方法是什么?我的一个想法是在我的 env 中添加一些东西。文件将添加一个变量以生成所有 perform_later s 进入 perform_now s - 但我不确定这样的标志或变量会是什么样子。

想法?

最佳答案

干净的解决方案是change the adapter在开发环境中。

在您的/config/environments/development.rb 中,您需要添加:

Rails.application.configure do
config.active_job.queue_adapter = :inline
end

"When enqueueing jobs with the Inline adapter the job will be executed immediately."

关于ruby-on-rails - 如何在本地将所有 'perform_later' s 转换为 'perform_now' s?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38233179/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com