I have a scaffold help requisition. There is a status field. Each request can have 3 statuses (pending, in_progress, finished), implemented through enum. It is necessary to write methods that will count the number of requests with each status. For example, method A counts how many total helper prequests with status 0 (pending). I understand that there is nothing complicated about this, but I can’t understand and could use some help.
1
I don’t know that you even need methods for this. Using enums provides a scope for the status, so you could just call, for example,
YourModel.in_progress.count
. That seems pretty idiomatic to me, and saves the nine lines of code needed to turn the counts into separate methods.