I’m planning out an application that will involve creating tickets and
assigning one or more staff to handle them, but I have a question about
the correct way to structure the relationships in Activerecord
The application is made up of Members and Staff, which are subtypes of
an STI User model. Either type of user can create a Ticket, but only
Staff can be assigned to them.
Here’s what I have so far, but I’m not sure if it created an infinite
loop
User::Member
has_many :tickets
User::Staff
has_many :tickets
has_many :tickets through :ticket_assignments
Ticket
belongs_to :user
has_many :staff through :ticket_assignments
I have a feeling that the STI model for both User types is going to be
the kink in the chain. Should I break it out? Is there another way to
model this? Should I go with a habtm join instead?
Still looking for help on this one. I submitted it late Friday night
(EST), so wanted to bump it for the Monday morning crowd. The full text
is below.
Thanks.
Chris B. wrote:
I’m planning out an application that will involve creating tickets and
assigning one or more staff to handle them, but I have a question about
the correct way to structure the relationships in Activerecord
The application is made up of Members and Staff, which are subtypes of
an STI User model. Either type of user can create a Ticket, but only
Staff can be assigned to them.
Here’s what I have so far, but I’m not sure if it created an infinite
loop
User::Member
has_many :tickets
User::Staff
has_many :tickets
has_many :tickets through :ticket_assignments
Ticket
belongs_to :user
has_many :staff through :ticket_assignments
I have a feeling that the STI model for both User types is going to be
the kink in the chain. Should I break it out? Is there another way to
model this? Should I go with a habtm join instead?
Thanks!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.