Rails: Design Pattern to Store Order of Relations
- by ChrisInCambo
Hi,
I have four models: Customer, QueueRed, QueueBlue, QueueGreen.
The Queue models have a one to many relationship with customers
A customer must always be in a queue
A customer can only be in one queue at a time
A customer can change queues
We must be able to find out the customers current position in their respective queue
In an object model the queues would just have an array property containing customers, but ActiveRecord doesn't have arrays.
In a DB I would probably create some extra tables just to handle the order of the stories in the queue.
My question is what it the best way to model the relationship in ActiveRecord? Obviously there are many ways this could be done, but what is the best or the most in line with how ActiveRecord should be used?
Cheers,
Chris