This question is more related to code quality and organization.
I am developing a Rails application, and we have some cron jobs that we execute daily. Those jogs are already working, but currently I am placing them inside my models, for example:
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
I use this method to update my order status, and this method is located inside my Order model.
My question is: Assuming rails best practices and conventions, is it correct to place this jobs inside my model? Or should I place this kind of methods somewhere else?
Creating a job class in the app/jobs directory is pretty common these days.