When I have only two statuses for an object, like ‘active’ and ‘retired’ for employee, I’d have a boolean field in the table users to account the user’s status.
But what should I do if I have an object with three or more statuses? A task may be ‘new’, ‘in progress’, ‘finished’ and ‘closed’, and a computer may be ‘ordered’, ‘in store’, ‘in use’, ‘in repair’ and finally ‘disposed’.
I can see several options:
1) Additional table ‘statuses’. Status belongs to task, task have one status. It looks ok for me, but it takes additional table.
2) Somehow have a list of statuses in the ‘users’ table. Don’t know if it’s possible. I’m using PostgreSQL.
3) Decide that 1 means ‘new’, 2 – ‘in progress’, 3 – ‘finished’ and use these numbers as stauses.
4) Use name of status as a status. Make the field ‘status’ a string.
What is the best Rails way?
I personally prefer the gems like state_machine or aasm where I have to create the string column for current state. So I think thats the right way because It gives me the information about the status right away.