Nested comments system

Hi everybody! Since theres not much documentation for awasome_nested_set , acts_as_commentable etc , im 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!

Vlad K. wrote:

Hi everybody! Since theres not much documentation for awasome_nested_set , acts_as_commentable etc , im 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
[email protected]

Marnen Laibow-Koser wrote:

Vlad K. wrote:

Hi everybody! Since theres not much documentation for awasome_nested_set , acts_as_commentable etc , im 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
[email protected]

i would really love to try it, but the rake documentation doesnt say much to me.. i fear im too newb for it.

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
[email protected]

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?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs