# Nested comments system

**URL:** <https://www.ruby-forum.com/t/nested-comments-system/175923>\
**Category:** Rails\
**Created:** [September 22, 2009, 10:11pm UTC](https://www.ruby-forum.com/t/nested-comments-system/175923 "2009-09-22T22:11:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 22, 2009, 10:11pm UTC](https://www.ruby-forum.com/t/nested-comments-system/175923/1 "2009-09-22T22:11:26Z")

</div>

Hi everybody! Since there`s not much documentation for awasome_nested_set , acts_as_commentable etc , i`m trying to build the  
nested comments in easy way :

event.rb  
…  
has\_many :comments  
…

comment.rb  
…  
belongs\_to :event  
…

the following method saves the comment:

def post\_comment  
@comment = Comment.new(  
“event\_id” =\> flash[:event\_id], # yes, i store it in flash  
“created\_at” =\> Time.now,  
“comment” =\> params[:comment][‘comment’],  
“commenter” =\> current\_user.login  
)  
if @comment.save  
…

what i want to do is add “parent\_id” column to comments table, add  
“parent\_id =\>…” to post\_comment. Then display a ‘Reply’ link under  
each comment. The problem is i have no idea how to pass parent\_id while  
replying comment

the comments are displayed by the partial :

- \<%=comment.commenter.capitalize%\> says:   
\<%= h comment.comment %\> 
 Posted \<%= comment.created\_at.strftime("%B %d, %Y at %I:%M %p") %\>  
 \<%= link\_to 'Reply', "something"%\> 

I added some comments with parent\_id manually to comments table, now i  
need the way to change my partial to display all the child comment for  
each parent comment.

i would really appreciate any suggestions/ideas . Thanks!

---

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 22, 2009, 10:25pm UTC](https://www.ruby-forum.com/t/nested-comments-system/175923/2 "2009-09-22T22:25:28Z")

</div>

Vlad K. wrote:

> Hi everybody! Since there`s not much documentation for awasome_nested_set , acts_as_commentable etc , i`m trying to build the  
> nested comments in easy way :

Bad idea. Go with awesome\_nested\_set . I don’t know why people keep  
saying it’s poorly documented – although the Github pages don’t say  
much, the rdoc is very clear.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 22, 2009, 11:19pm UTC](https://www.ruby-forum.com/t/nested-comments-system/175923/3 "2009-09-22T23:19:05Z")

</div>

Marnen Laibow-Koser wrote:

> Vlad K. wrote:
> 
> > Hi everybody! Since there`s not much documentation for awasome_nested_set , acts_as_commentable etc , i`m trying to build the  
> > nested comments in easy way :
> 
> Bad idea. Go with awesome\_nested\_set . I don’t know why people keep  
> saying it’s poorly documented – although the Github pages don’t say  
> much, the rdoc is very clear.
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid

i would really love to try it, but the rake documentation doesn`t say much to me.. i fear i`m too newb for it.

---

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 23, 2009, 12:11am UTC](https://www.ruby-forum.com/t/nested-comments-system/175923/4 "2009-09-23T00:11:00Z")

</div>

Vlad K. wrote:

> please, guys, can somebody just throw me some theory/suggestions.
> 
> I have the comment models  
> event.rb which has\_many :comments
> 
> and comment.rb which belongs\_to :event and acts\_as\_nested\_set (awasome  
> one)
> 
> how do i manage the comments?

What are you asking here? About dealing with parent\_id? You can pass  
that in the URL or similar. I’ll try to check how I did this last time  
I had to…

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![vladk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/cdc98d/32.png) [@vladk](https://www.ruby-forum.com/u/vladk)\
**Post date:** [September 22, 2009, 11:32pm UTC](https://www.ruby-forum.com/t/nested-comments-system/175923/5 "2009-09-22T23:32:12Z")

</div>

please, guys, can somebody just throw me some theory/suggestions.

I have the comment models  
event.rb which has\_many :comments

and comment.rb which belongs\_to :event and acts\_as\_nested\_set (awasome  
one)

how do i manage the comments?
