ruby - Rails - Correct location to place cron jobs -
this question more related code quality , organization.
i developing rails application, , have cron jobs execute daily. jogs working, placing them inside models, example:
def update_boleto_orders_payment_status orders = order.boleto_unpaid_orders orders.each |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 method update order status, , method located inside order model.
my question is: assuming rails best practices , conventions, correct place jobs inside model? or should place kind of methods somewhere else?
creating job class in app/jobs directory pretty common these days.
Comments
Post a Comment