Wednesday, May 18, 2022

[FIXED] How can I yield a "future" content_for tag in Rails 3?

Issue

I have a template with 2 partials. In the first one, I am yieleding content which is only defined in the second partial (with a content_for tag). The problem is that the yield does not recognize that content yet since it was not defined.

If I reverse the order of the partials the yield recognized the content, yet the layout is not as I desire obviously...

Is there a way to do this? Thank you.


Solution

Okay, this was actually an easy fix. I moved the second partial into a content_for block placed above the first partial, and then just yielded it instead of declaring it as a partial.



Answered By - Indigon
Answer Checked By - Senaida (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.