1
J'écris aide pour rendre la tête de table htmlComment rendre cette fonction html_safe?
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
La sortie html est échappé:
<table><thead><tr><th>Header</th><th>Header</th></tr></thead></table>
Comment puis-je faire non échappés?
[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
La jointure de thank a résolu le problème. Mais je n'arrive toujours pas à comprendre pourquoi concat gâcher les choses. Pouvez-vous m'éclairer? –
En bref: non. Je n'ai jamais utilisé 'concat'. ;-) – Reactormonk