Very simple question really, but it's driving me nuts.
I have this method call in a Rails view:
<%= get_image(@document) %>
The method in here returns an object of type ActiveSupport::SafeBuffer
. If I call .to_str
on it in a console, I see the expected result (just an html img tag). However, when I stick the above code in a view, there's nothing there. Just an empty string.
If I do this:
<%= get_image(@document).to_str %>
in an effort to convert the SafeBuffer
into a String
object, I see the literal HTML in the page, and not the image tag.
I feel like I'm missing something simple or elementary here. Can anyone point the way? Thanks in advance!
EDIT: since it's been requested, here's what the get_image
method looks like:
def get_image(document)
document[document.type+'.image'].nil? ? nil : document[document.type+'.image'].as_html_safe
end
am i rendered?
'.html_safe %> -- that too should be a SafeBuffer. – Brian Oct 16 '15 at 17:38am i rendered?
'.html_safe.to_s? Also, what exactly does the get_image call give you? – Brian Oct 19 '15 at 19:33