Rails - 放置 cron 作业的正确位置

Rails - Correct location to place cron jobs

这个问题与代码质量和组织更相关。

我正在开发一个 Rails 应用程序,我们有一些每天执行的 cron 作业。这些慢跑已经开始工作,但目前我将它们放在我的模型中,例如:

def update_boleto_orders_payment_status
    orders = Order.boleto_unpaid_orders
    orders.each do |o|
      order = HTTParty.get("https...",
                    headers: {"Authorization" => "Basic #
{encode_auth_token}"})
      order_status = JSON.parse(order.body).symbolize_keys![:status]
      o.update_column(:paid, true) if(order_status.eql? "AUTHORIZED")
    end
  end

我使用这个方法来更新我的订单状态,这个方法位于我的订单模型中。

我的问题是:假设 rails 最佳实践和约定,将此作业放入我的模型中是否正确?或者我应该把这种方法放在其他地方吗?

现在在 app/jobs 目录中创建作业 class 很常见。