Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:28:03+00:00 2026-06-04T20:28:03+00:00

As you can see I have a helper with a method that I’m trying

  • 0

As you can see I have a helper with a method that I’m trying to render out to the view.

The nested content_tags do not render what is my disconnect about this tag?

def draw_calendar(selected_month, month, current_date)
  content_tag(:table) do

    content_tag(:thead) do

      content_tag(:tr) do

        I18n.t(:"date.abbr_day_names").map{ |day| content_tag(:th, day, :escape => false) }

      end #content_tag :tr
    end #content_tag :thead 

    content_tag(:tbody) do 

      month.collect do |week| 

        content_tag(:tr, :class => "week") do

          week.collect do |date| 

            content_tag(:td, :class => "day") do

              content_tag(:div, date.day, :class => (Date.today == current_date ? "today" : nil))

            end #content_tag :td
          end #week.collect
        end #content_tag :tr
      end #month.collect
    end #content_tag :tbody 
  end #content_tag :table
end #draw_calendar

::: EDIT :::

So here is what worked. Thanks again mu is too short!

def draw_calendar(selected_month, month, current_date)
  tags = []

  content_tag(:table) do

    tags << content_tag(:thead, content_tag(:tr, I18n.t("date.abbr_day_names").collect { |name| content_tag :th, name}.join.html_safe))

    tags << content_tag(:tbody) do 

      month.collect do |week| 

        content_tag(:tr, :class => "week") do

          week.collect do |date| 

            content_tag(:td, :class => "day") do

              content_tag(:div, :class => (Date.today == current_date ? "today" : nil)) do

                date.day.to_s

              end #content_tag :div
            end #content_tag :td
          end.join.html_safe #week.collect
        end #content_tag :tr
      end.join.html_safe #month.collect
    end #content_tag :tbody 
    tags.join.html_safe
  end #content_tag :table
end #draw_calendar

end

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:28:04+00:00Added an answer on June 4, 2026 at 8:28 pm

    Your problem is that content_tag wants its block to return a string, you can trace through the code to see that it uses capture from CaptureHelper and that ignores any non-string return from the block.

    You need to turn your collects into strings with something like this:

    content_tag(:tbody) do 
      month.collect do |week| 
        content_tag(:tr, :class => "week") do
          week.collect do |date|
            ..
          end.join.html_safe
        end
      end.join.html_safe
    end
    

    For example, a helper like this:

    content_tag(:table) do
      content_tag(:thead) do
        content_tag(:tr) do
          [1,2,3,4].map do |i|
            content_tag(:td) do
              "pancakes #{i}"
            end
          end
        end
      end
    end
    

    produces:

    <table>
        <thead>
            <tr></tr>
        </thead>
    </table>
    

    but adding the .join.html_safe:

    content_tag(:table) do
      content_tag(:thead) do
        content_tag(:tr) do
          [1,2,3,4].map do |i|
            content_tag(:td) do
              "pancakes #{i}"
            end
          end.join.html_safe
        end
      end
    end
    

    produces the expected:

    <table>
        <thead>
            <tr>
                <td>pancakes 1</td>
                <td>pancakes 2</td>
                <td>pancakes 3</td>
                <td>pancakes 4</td>
            </tr>
        </thead>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying not to lose it here. As you can see below I have assigned
I have a Mercurial repository that I can see just fine if I navigate
I have something that looks like this: As you can see, Blambo is a
I have the following two methods that (as you can see) are similar in
Say I have a things resource with a view helper method such as: module
I have a view and it uses TextBoxFor helper method to edit model. Like
I have an Extension Method that verifies if the user is able to see
I have a method in my application helper that is meant to deactivate a
I have this: As you can see I currently have a conditional to include
I have the following HTML and you can see the extra space between the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.