views:

26

answers:

1

Hi!

I'm writing helper to render html table header

def display_standard_table(columns)
  content_tag :table do
    content_tag :thead do
      content_tag :tr do
        concat columns.collect { |column| content_tag(:th, 'Header'.html_safe) }
      end
    end
  end
end

The html output is escaped:

<table><thead><tr>&lt;th&gt;Header&lt;/th&gt;&lt;th&gt;Header&lt;/th&gt;</tr></thead></table>

How do I make it unescaped?

[SOLUTION]

def display_standard_table(columns, objects = [])
  content_tag :table do
    content_tag :thead do
      content_tag :tr do
        columns.collect { |column| content_tag(:th, column[:display_name]) }.join()
      end
    end
  end
end
+2  A: 

concat? use join on the mapped array and see what happens.

Tass
thank's join solved the issue. But i still can't understand why concat mess up things. Can you clearify it to me?
Adrian Serafin
In short: no. I never ever used `concat`. ;-)
Tass