title: Understanding Rails ActiveRecord "single model" self joins
body: <p>I'm having a hard time understanding how to implement a single model self-join in Rails. 
  The <a href="http://guides.rubyonrails.org/association_basics.html" rel="noreferrer">Guide to ActiveRecord Associations section 2.10</a> briefly explains Self-Joins but doesn't offer enough information, and every example or post about this such references the Friendly Friend Railcast example that isn't a single model self join, as described in the <a href="http://guides.rubyonrails.org/association_basics.html" rel="noreferrer">Rails Guide section 2.10</a>.</p>
  
  <p>The idea is a model that has_many and belongs_to itself, without needing a separate table for the relationship. The only reason I see for needing a separate table is if you want the relationship to contain more information than just the relationship. e.g. "best friends", "barely know them"</p>
  
  <p>I have a simple Post schema:</p>
  
  <pre><code>create_table "posts", :force =&gt; true do |t|
      t.datetime "posted"
      t.string   "nick"
      t.string   "title"
      t.text     "content"
      t.integer  "parent_post_id"
      t.datetime "created_at",     :null =&gt; false
      t.datetime "updated_at",     :null =&gt; false
  end
  </code></pre>
  
  <p>The parent_post_id is a self-reference to other Post post_id's. The posts.rb model has the relationship defined:</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    has_many :replies, :class_name =&gt; "Post"
    belongs_to :parent_post, :class_name =&gt; "Post",
      :foreign_key =&gt; "parent_post_id"
  end
  </code></pre>
  
  <p>In the Controller or View I'm hoping to be able to do something like this:</p>
  
  <pre><code>@posts.each do |post|
    ...
    @replies = post.replies
    @replies.each do |reply|
      ...
    end
  end
  </code></pre>
  
  <p>Or find a post's parent:</p>
  
  <pre><code>@parent_post = post.parent_post
  </code></pre>
  
  <p>This may all be some syntax mis-understanding. So thanks in advance to anyone who can slap some sense into me. I've looked through every SO and blog post out there and none try the single model self-referential self-join method described in the Guide.</p>
  
  <p>Points for anyone offering an explanation that doesn't point to the Friendly Friend example that uses a separate relationship table.</p>