Answer the question
In order to leave comments, you need to log in
How to write a Worker to change status?
There is an Order model, which has a "status" field of type string.
You need to write a worker that, after a certain time, will change the status of each order to the next one, up to the last one. Statuses, I think, should be placed in the constant STATUSES = %w(in_progress approved shiped received). Well, to make it work on Heroku.
What is the best way to implement this? Previously, I did not have to write workers, so I ask for help from you. Thanks in advance
Answer the question
In order to leave comments, you need to log in
And enum instead of constants.
If additional logic is required when changing statuses - a state machine. For example, aasm .
If the shift needs to be done at a certain time (for example, an hour after creation) - you can get by with one sidekiq. If every hour or at midnight - clockwork will help .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question