Comment has_many comments

You may want to look at Single Table Inheritance for this. That's a pretty simple way to make a linked list, which is what you're describing.

Walter

Walter, can you give a link or a brief description on how to use STI
to implement a linked list, or a link to a description? I have not
come across that idea before.

thanks

Colin

Hi,

I want to create web application where people can discuss some things.
There will be a Posts and users can comment it, but I also want users can comment commentaries.
Can I create model comment, that belongs_to comment and has_many comments, or smth similar?

I only studying Rails. Sorry for my bad english.

You may want to look at Single Table Inheritance for this. That's a pretty simple way to make a linked list, which is what you're describing.

Walter, can you give a link or a brief description on how to use STI
to implement a linked list, or a link to a description? I have not
come across that idea before.

I am pretty sure I am mis-remembering the name of the thing. The more I look at it, the more wrong I think I am here.

Sorry for the noise. I'll try to remember what I was thinking of here...

Walter

Hi,

I want to create web application where people can discuss some things.
There will be a Posts and users can comment it, but I also want users can comment commentaries.
Can I create model comment, that belongs_to comment and has_many comments, or smth similar?

I only studying Rails. Sorry for my bad english.

You may want to look at Single Table Inheritance for this. That's a pretty simple way to make a linked list, which is what you're describing.

Walter, can you give a link or a brief description on how to use STI
to implement a linked list, or a link to a description? I have not
come across that idea before.

I am pretty sure I am mis-remembering the name of the thing. The more I look at it, the more wrong I think I am here.

Sorry for the noise. I'll try to remember what I was thinking of here...

Maybe this: https://github.com/stefankroes/ancestry

Not a linked list, but something called a "materialized path".

I figured out why I was thinking STI -- I made a forum years ago that had Threads and Comments, organized in an STI table. There was only one layer of inheritance, not what the OP was asking for. If you were only ever looking at a chronological list of comments, you could have a :parent attribute that was a self-reference to another record in the same table. That could give you your nesting structure, simply by looking up the chain of ancestors to the root.

Walter