title: RoR: STI / MTI / Mixin confusion
body: <p>i have a problem which is i believe basic for most of the RoR developers. In fact, it's more about "understanding" than really programming it (i have already been programming a few modules to be able to extend ActiveRecord::Base to allow easy generation of Ext-JS related things without any problem).</p>
  
  <p>Let's take a simple example, i'll talk in an ORM oriented language rather than a database / model language.</p>
  
  <ul>
  <li>ThirdParty is a basic entity, having a common member named 'label'.</li>
  <li>A ThirdParty instance can be a Customer, a Supplier, both, or none of them (So Customer / Supplier are like concrete interfaces rather than inherited classes).</li>
  <li>Both Customer and Supplier have specialized members, which are for most of them unique to each respective class (Customer  / Supplier don't share much data except the label field they are bound to via ThirdParty).</li>
  </ul>
  
  <p>i have tried to do various things:</p>
  
  <ul>
  <li>ThirdParty &lt; ActiveRecord::Base</li>
  <li>Customer &lt; ThirdParty</li>
  <li>Supplier &lt; ThirdParty</li>
  </ul>
  
  <p>[EDIT]
  Missed my explanation here. i meant: one single instance of ThirdParty could be a customer, a supplier, BOTH, OR NONE.
  As the first commenter pointed out, my example might not be the best... You can replace "ThirdParty" by "Character", and "Customer" / "Supplier" by "Archer" / "SwordsMan". A character can either be one, two, both, or none, but would provide the information on any instance of Character. The getters on Archer / SwordsMan shall return instances of Character "implementing" the interface contract, rather than just returning an instance of themself with a "getter" on the character object.
  [/EDIT]</p>
  
  <p>Also i have tried:</p>
  
  <ul>
  <li>ThirdParty &lt; ActiveRecord::Base (has_one Customer; has_one Supplier)</li>
  <li>Customer &lt; ActiveRecord::Base (belongs_to ThirdParty)</li>
  <li>Supplier &lt; ActiveRecord::Base (belongs_to ThirdParty)</li>
  </ul>
  
  <p>But it seems a bit "ugly" to me, because i have to do Customer.find(something).third_party.label to access data "inherited" by my "interfaces".</p>
  
  <p>Also, i could include a customer_id and a supplier_id field on my ThirdParty model, but it doesn't seem right neither, because one ThirdParty can be both, or none of them...</p>
  
  <p>And of course, i'd like to be able to find a solution which isn't obstructive / too much of a hack, to allow me for instance to then do some polymorphic association for another model (Such as an addressable, or commentable, contactable, etc...)</p>
  
  <p>i also have been reading a lot on the subject like on such blog: <a href="http://mediumexposure.com/multiple-table-inheritance-active-record/" rel="nofollow">http://mediumexposure.com/multiple-table-inheritance-active-record/</a> ... But i'am lost in the right way to do it (On most of the documentation i have found on the subject isn't clear if it's for Rails 1, 2, 3... What's recently been implemented on the matter, etc).</p>
  
  <p>Can someone provide me with various "up-to-date" websites or to an example fitting the example i have given?</p>
  
  <p>By advance, i thank you all for having red my question, and to edventually explain me the different techniques used regarding this particular subject.</p>
  
  <p>P.S.: If you need me to explain more what i'm looking for, i can try... But keep in mind that my english is a bit "limited" on this domain, since i'm relatively new to RoR.</p>