I have the following two models and am not quite sure how they should be
associated.
- Car
- CarWashStation
At any given time, an instance of Car will be at (belong to?) one of a
dozen car wash stations. What associations should I use (if any) between
these models?
I would anticipate a CarWashing model, which has_one Car and one
CarWashStation, along with details about the time of the washing, what
soap was used, and which attendants conducted it (through an
AttendantsCarWashings join table), etc. A Car would then have many
CarWashings, and a named scope could give the current_car_washing.
Or something like that.
I just realized CarWashStation might be misleading. Each station refers
to one "activity location" that the car mush move through per wash. A
few example instances might be:
- Soap Application Station
- Bristle Brush Station
- Wax Station
- Dry Station
That sounds like a CarWashing should have a state-machine to manage
transitions between stations (rather than stations being models of
their own).
You could have sub-types of CarWashing that would provide different
combinations of states (for the simple Wash'n'Wax to the full-on
hand-finished-chamois-wipe-down-with-under-body-jet-wash).
I'll look into what a state machine is. Thanks for that.
Each station currently has many to do items as well as a uptime status
and employees operating in that station. Does it still make sense for
stations to not be their own model?