I have a User model, which has a state. The state can be either of these: [‘unverified’, ‘active’, ‘deleted’]
What is the best way to store the state of the object in the database?
Should I create three boolean fields? That would not make a lot of sense, since I might want to extend the number of states easily and only one state can be ‘true’ at the same time.
Should I use the state_machine gem just for simple switching of constant values?
Or is there any other common way, best practice, or a simple gem for this kind of job?
A very simple solution I’ve used for this:
In your migration
In your model
Then you can call
Or