我正在开发一种产品,该产品调用 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/