title: Need help with polymorphic join table in rails
body: <p>Hi gys i am trying to link two entities to one entity which is governing body, estate and repo_document, then a governing body can have repo_document that the estate can also have so i decided to create a join table named document_owner.. but i dont know what to write in their models..i have got this code in my document_owner model..</p>
  
  <blockquote>
  <pre><code>belongs_to :repo_document
  belongs_to :estate, :through =&gt; :repo_document, :foreign_key =&gt; :owner_id, :conditions =&gt; "owner_type = 'Estate'"
  belongs_to :governing_body, :through =&gt; :repo_document, :foreign_key =&gt; :owner_id, :conditions =&gt; "owner_type = 'GoverningBody'"
  belongs_to :owner, :polymorphic =&gt; true
  </code></pre>
  </blockquote>
  
  <p>and this one in my repo_document</p>
  
  <blockquote>
  <pre><code> has_and_belongs_to_many :owners, :join_table =&gt; :document_owners, :conditions =&gt;     "owner_type = 'Estate' OR owner_type = 'GoverningBody'"
  </code></pre>
  </blockquote>
  
  <p>and this one in my estate</p>
  
  <blockquote>
  <pre><code>has_many :repo_documents, :source =&gt; :document_owners, :foreign_key =&gt; :owner_id, :conditions =&gt; "owner_type = 'Estate' "
  </code></pre>
  </blockquote>
  
  <p>and this one in my governing_body</p>
  
  <blockquote>
  <pre><code>has_many :repo_documents, :source =&gt; :document_owners, :foreign_key =&gt; :owner_id, :conditions =&gt; "owner_type = 'GoverningBody' "
  </code></pre>
  </blockquote>
  
  <p>but when i try to save it does not save anything inside the join table..</p>
  
  <p>can anybody help me please</p>