Ruby on Rails Friday, June 23, 2017

> On Jun 23, 2017, at 5:29 PM, fugee ohu <fugee279@gmail.com> wrote:
>
> There's only one list of comments per post so why can't the link for a new comment be in the comments partial In any resource the index view has a link to new, from the folder for that resource ... i dunno, are you sure it has to be in the post folder/containers?


The link is in the _comment partial (singular). There is no _comments (plural) partial. If there was, then you could put the link there. But here's the thing. A post has_many comments. Until the first one is put in, you will see zero comments, and thus (if you put the link in the _comment (singular) partial, there won't be any link, because the _comment partial will be rendered zero times.

But further, if you put it where you did, you have some more problems. You will have a new link below each comment. Unless you are planning to allow comments on comments (some sort of threaded nesting structure), then this will look awful and make no sense. So if you are somehow able to render the first comment, the second one will get its own Add Comment link. Beyond that, in order to inject the form into the page the way you want to, you need to insert the form into some identifiable DOM object, which you didn't provide in your sample templates.

Please try what I suggest -- I've been doing this for a large number of years, sometimes badly and without understanding, and I'd like to see the penny drop for you. I promise it can make sense once you stop pushing so hard to go a different way.

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CB3EC818-8BFB-4BB5-8EAE-56F25909A31E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment