0

I'm interested in the question of the two-level comments

for example: I use some post with comments list

The user can add his/her own comments, and in my app I show all comments like that:

<div id='com'>
    <%= render @post.comments %>
</div>

in my view/comments/_comment:

<div class='comments'>
    <p>
      <strong>Commenter:</strong>
      <%= comment.commenter %>
    </p>
    <p>
      <strong>Comment:</strong>
      <%= comment.body %>
    </p>
    <%= link_to "Del", [comment.post, comment], :confirm => 'Are you sure?', :method => :delete %>
    <hr>
</div>

in my comments table I have post_id and body of comment ( and other fields ) and my View, I show all comments to post by created_at (I not sure but I think this is right assumption ) because I use <%= render @post.comments %>

And that is question: I don't understand how can I realize two-level comments?

I am also looking for simple examples on this theme, please. or tell me the main idea of this implementation...

UPD:

i create some post in my blog : first user commented it, second user commented it, third user commented it

than i open post, saw three comments and i disagreed with first commenter - and i want put my comment between first commenter and second commenter - how can i realize that?

Dmytro Vasin
  • 823
  • 2
  • 11
  • 22
  • well so far i could get from your questions is, you are showing `comments` of a `post` by the order of its **creation date**. Then what did you really meant by **two level comments**? Do you think that you can rephrase your problem? – Samiron Sep 23 '12 at 13:18

1 Answers1

1

Please follow the updated part first

So you mean your comments can have a comment as parent. In the case you described, the comment from the first user is the parent of your comment. If I got it correctly, then the best suggestion is to use acts_as_tree plugin. Your comments model should act like a tree. Try using this https://github.com/rails/acts_as_tree.

If you are using rails3 then Acts-as-tree in Rails3? might help. Let me know if you face any problem using the plugins.

Update:

Another googling gave me these links. I think you need exactly this implementation.

Community
  • 1
  • 1
Samiron
  • 5,169
  • 2
  • 28
  • 55