Reputation: 607
I'm making a survey that has a bunch of different response types (BooleanResponse, TextResponse, etc.) via Single Table Inheritance. In my view, I'd really like to be able to call a method like response.render
and have that return html code. Is this possible to do? What do I have to write in the method to make the return type compatible with an html.erb view?
(I know this can also be done in the view or the view helper with a long case/switch statement, but I'd much prefer to do it this way)
Upvotes: 1
Views: 235
Reputation: 52357
All you have to do to make the method return html is to use html_safe
:
def method_that_returns_html
data = '<strong>Your html here</strong>'
data.html_safe
end
Upvotes: 1