1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This is your Articles Controller (/app/controllers/article_controller.rb)
class ArticlesController < ApplicationController
  
  def show
    # This would be accessed at www.mysite.org/articles/show/1
    @article = Article.find params[:id]
  end
  
end

# This is /app/views/articles/show.rhtml
<h2><%= @article.title %></h2>

<p>
  <%= @article.body %>
</p>

<% if @article.has_comments? %>
  <ul>
    <%= render :partial => 'comment', :collection => comment.children %>
  </ul>
<% end %>

# This is /app/views/articles/_comment.rhtml
<li>
  <%= comment.title %>

  <p>
    <%= comment.body %>
  </p>
  
  <% if comment.has_children? %>
    <ul>
    <%= render :partial => 'comment', :collection => comment.children %>
    </ul>
  <% end %>
  
</li>