At this point, you should be able to look around a small codebase like this and figure it out, but here are the “hints”:

If you don’t get how this is working, point to a specific thing and ask a more directed question.


P.S. The routes could easily be amended to be:

resources :comments, except: [:new]

Yes thanks, that’s what I’ve been doing

Why does comments/_reply.html.erb have to recursively render itself again after the form ?

I put a new action in the comments controller since you don’t use a link to new you render the form instead

Because you can reply to a comment and then someone could reply to your reply, etc. Note that the recursive call is only for the comment.children so it won’t go on forever.


Unless you’re changing other parts, too. You will NEVER hit the :new action because you ALWAYS create the comment form in the context of a Post or another Comment. Like I said, you could add , except: [:new] to the route if it bothers you.


So in your example the forms already on the page in index view instead of a link to new comment? If yes whats wrong with a link to new comment instead of a text area and submit button already rendered?

If you do that, you need to pass the “parent” object to the new action. There’s nothing “wrong” with that. You probably need to define your own new_comment route if you want the URL to look nice and not have query parameters to define the parent object. (If you intend to eliminate threaded comments where the parent is another comment, you have just a little more work to do, but then you might not even need Comment to be polymorphic [if you can’t comment on more than one kind of model].)