I'm updating my rails 2 apps to rails 3 and find that the use of 'render :text' does not behave the same anymore.
@results is an array. In my controller:
render :text => "<ul>#{@results}</ul>"
It's returning the whole array as a string rather than iterating through each value:
<ul>
["
<li>Steve</li>
", "
<li>John</li>
"]
</ul>
Worked fine in Rails 2.x but not in 3. How do I fix this?
I'm expecting a result of:
<ul>
<li>Steve</li>
<li>John</li>
</ul>
Content-Type
header totext/plain
(among the charset). If you came here looking for how to render HTML (but not in a template file), userender html: '<div>...</div>'
. That sets the header totext/html
and your browser will know to parse the hTML. (Potentially call.html_safe
on your html string, but be careful.) – Bole