I have the following code in one of my helpers:
def send_fragments_to_other_template(template, counter)
if counter == 0
content_tag "div", class: "card w-5c" do
content_tag "div", class: "card__content resource" do
content_tag "h4" do
content_tag "span", "Send fragments to other template"
end
link_to "Send", edit_admin_template_fragment_path(template), class: "btn btn--s-purple", remote: true
end
end
end
end
Here's the problem: for whatever reason, the third and fourth content tags are being ignored by rails. I have the two divs and the button (anchor), but not the h4 or the span, on the page.
What am I doing wrong ?
It looks similar to this post on stack overflow: Why does this nested content_tag not render properly? What's happening here is that content_tag renders just the last expression from the do-end block. That's probably why you can see the "Send" button and not the others. I would prefer using concat, which behaves like puts, to get past this. It's the second answer in the post above^.