This question is very similar to "Ruby array to string conversion", but in my case, and using the table ['12','34','35','231'], I want to get a string like:
'12' &
'32' &
'35' &
'231'
The idea is to construct a string in a decorator method called content, and when I display that specific string in the view <p><%= table.content %></p>, I want it to render automatically as showed, without adding any HTML tags in the view, basically mimicking the <br> tag between each two lines.
What I have already is:
def content
string = "Table content "
table = ['12','34','35','231']
string = table.map do |row|
row
end
"#{string.join(" & \n")}"
end
Any clues?
<pre>tag if you want it to display correctly.table.join(" &<br/>").html_safe. Yourtable.mapblock just yields an arraystringthat looks just liketable.