title: How to manage table without id in Rails?
body: <p>I have two models: Person and Relation. The second one stores information about relations between two people. It has parent_id and child_id fields and doesn`t have id field. I connected it with has_many :through and it works.</p>
  
  <p>But:</p>
  
  <ol>
  <li>Relation.find(:all) returns empty array even if there are some relations in the table (becouse there is no id field).</li>
  <li>I don`t know how to delete relation.</li>
  </ol>
  
  <p>My models looks like this:</p>
  
  <pre><code>class Person &lt; ActiveRecord::Base
    has_many :child_relations, 
             :class_name =&gt; "Relation", 
             :foreign_key =&gt; "parent_id"
    has_many :parent_relations, 
             :class_name =&gt; "Relation", 
             :foreign_key =&gt; "child_id"
  
    has_many :children, :through =&gt; :child_relations
    has_many :parents, :through =&gt; :parent_relations
  end
  
  class Relation &lt; ActiveRecord::Base
    belongs_to :parent, :class_name =&gt; "Person"
    belongs_to :child, :class_name =&gt; "Person"
  end
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>UPDATE: I've used <strong>has_many :through</strong> becouse I also store information about a type of the relation in the table. Currently I gave up and I added id field to my table (Rails convention...). But my question remains open.</p>