Ruby on Rails Friday, June 23, 2017

> On Jun 23, 2017, at 5:58 PM, Walter Lee Davis <waltd@wdstudio.com> wrote:
>
>
>> 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 may want to read this step-by-step I wrote for a lunch-n-learn at Penn: https://gist.github.com/walterdavis/3a960dfdc529a5adf0dd6cff9e644fb0

It covers starting with a fully inline layout, and moving into partials. Funny enough, it features articles and comments.

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/C7B1D4BF-6529-4043-8486-62441C84B5B3%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment