How make this function html_safe?
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><th>Header</th><th>Header</th></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
concat
? use join
on the mapped array and see what happens.
精彩评论