title: How to to get the list of all parents from relationships table
body: <p>I am using Ruby on Rails 3.0.9. I am trying to get the list of all the parents from the relationships table. Here is code.</p>
  
  <pre><code>require 'rubygems'
  gem 'activerecord', '3.0.9'
  require 'active_record'
  
  ActiveRecord::Base.establish_connection( :adapter  =&gt; 'sqlite3', 
                                           :database =&gt; ':memory:')
  
  ActiveRecord::Schema.define do
    create_table :people, :force =&gt; true do |t|
    end
    create_table :relationships, :force =&gt; true do |t|
      t.integer :parent_id
      t.integer :child_id
    end
  end
  
  class Person &lt; ActiveRecord::Base
  end
  
  class Relationship &lt; ActiveRecord::Base
    belongs_to :parent,   :class_name =&gt; 'Person'
    belongs_to :child,    :class_name =&gt; 'Person'
  end
  
  child = Person.create!
  parent = Person.create!
  Relationship.create!(:parent_id =&gt; parent.id, :child_id =&gt; child.id)
  
  # Person.parents_list needs to be implemented and 
  # I am stuck and do not know how to get to that
  assert 1, Person.parents_list.size 
  assert parent.id, Person.parents_list.first.id
  </code></pre>