Given that I have a house model and it lives through several states, something like this: Dreaming β> Planning β> Building β> Living β> Tearing down
If I wanted to get, say, ten houses from the database and sort them by state field, I would first get all the houses in the Building state, then Dreaming , then Living , ...
Is it possible to get all the houses from the database and arrange them according to the state in the order intended before they were extracted? Meaning, at first everyone at home is in a Dreaming state, then Planning , etc., for example. by providing order in an array to compare varieties.
I would like to avoid this in ruby ββafter having selected all the records, and also would not want to use identifiers for states.
UPDATE
After reading on enum implementations, I think if I can get it to work, I will try to combine the enum column plugin using the state_machine plugin to achieve what I need. If someone had done something similar before (especially the combination under Rails 3), I would be grateful for the input!
source share