please help solve the problem. i use gem 'ancestry'. i made simply blog. messages_helper.rb:
module MessagesHelper
def nested_messages(messages)
messages.map do |message, sub_messages|
render(message) + content_tag(:div, nested_messages(sub_messages), :class => "nested_messages")
end.join.html_safe
end
end
index.html.erb:
<%= nested_messages @messages.arrange(:order => :created_at) %>
<br>
<%= render 'form' %>
schema:
create_table "messages", force: :cascade do |t|
t.text "content"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "ancestry"
end
in result i output to index.html.erb tree of messages with related messages. but i need output only certain message with related messages. e.g. for message with id=3
ps: for made blog i use this tutorial: http://railscasts.com/episodes/262-trees-with-ancestry