When I used Rails a couple of years ago, it was all fat models and skinny controllers. From what I understand that has shifted slightly.
I have two models: Job
and Run
. A job has many runs and a run belongs to a job.
Both jobs and runs has a status attribute and they can have these possible values:
- Job: unknown, success, failure
- Run: unknown, success, failure, running
The run status is updated based on running a shell command.
When the run status is updated, the job status should be updated with the same status (unless status is running). The job status can also be updated using a form.
When the job status is updated, an email should be sent if the status is changed.
The way I would have implemented this back in the day, I would have added an after save action to both job and run.
But actions can get quite messy and if I understand it correctly, that's why some people recommend using some other type of (service) classes for things like this?
How would you implement the above?
Aucun commentaire:
Enregistrer un commentaire