Answer the question
In order to leave comments, you need to log in
How to correctly make an order status?
Suppose there is an Order model .
How to correctly organize the order status: add a boolean field to this model (Processed / Not processed). Or create a separate association, for example, has_one :status and treat it as a single small resource, i.e. organize create/destroy actions in a separate controller?
Answer the question
In order to leave comments, you need to log in
If there are only two statuses (Processed / Not processed), then a boolean is enough.
If there are a lot of statuses, then it is better to fasten the state-machine (AASM / Workflow). In this case, it will be possible to make different actions with the order available in different statuses.
If there are many statuses, but the state machine is redundant (or too lazy to mess with it), then you can use the standard enum rail feature ( edgeapi.rubyonrails.org/classes/ActiveRecord/Enum.html ).
Creating a separate model is somehow completely redundant. Only if there is some other functionality there, but I can’t think of an example right away.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question