STI and has many relationships

Looking at the example in Obie’s book.

Class Place < ActiveRecord::Base
end

class State < Place
has_many :counties
has_man :cities
end

class County < Place
belongs_to :state
has_many :cities
end

class City < Place
belongs_to :county
end

Here we have a STI which has self joins.

Let’s say we wanted to add Politicians into this model. A politician
can belong to either State, County or City. What is the proper way to
add the Politician.

Do you go into all the models and add a has_many :politician?

Do you only add the has_many into the place model?

Do you make the relationship between politicians and cities, counties,
states polymorphic?

How about the politician class so you add a belongs_to :place or do
you add a belongs_to :city, belongs_to :state etc?

TIA.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs