Nested commenting system without using any Gem

We all know, Comments are every where Blogs, Social Networking sites, e-learning forums etc. In this article, we've got an Article model and we want to create a nested commenting system onto that. Such that Article can have comments, comments can have replys, replys can have more replys and so on. For example - This is an article This is an comment this is a reply this is a reply's reply .... (so on) This is another comment. Now, we're going to talk about polymorphic associations and what they are and how they can be implemented for nested commenting system. What

Nested Forms

Feature is used when you need to save your nested model with the parent model. Use-Case: Suppose you have a model say Person and it can be associated with N number of Contacts. Using nested form we can associate 1..n contacts to the person. Approach: For associating a contact to a person, we need to build the contact model with respect to the person model. For has_many relation, @contact = @person.contacts.build and if has_one relation @contact = @person.build_contact. Now we can use the @contact in the view, for this we use fields_for tag. And