# STI and has many relationships

**URL:** <https://www.ruby-forum.com/t/sti-and-has-many-relationships/145465>\
**Category:** Rails\
**Created:** [August 10, 2008, 5:18am UTC](https://www.ruby-forum.com/t/sti-and-has-many-relationships/145465 "2008-08-10T05:18:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_U](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90db22/32.png) [@Tim\_U](https://www.ruby-forum.com/u/Tim_U)\
**Post date:** [August 10, 2008, 5:18am UTC](https://www.ruby-forum.com/t/sti-and-has-many-relationships/145465/1 "2008-08-10T05:18:13Z")

</div>

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.
