Search code examples
ruby-on-railsinnerhtml

Render inner html in rails view


I have a model with name book. Book has a description. Admin will add this description using ck-editor. So I need to display this description to user using innerHtml. And I have no idea about how to render innerHtml in rails. Any help will be appreciated.

If I add the following description from admin within (bold) tag

Ruby On Rails is awesome

It should display in as Ruby On Rails is awesome but I am unable achieve this.

Sample Code <%=@my_variable%>

where @my_variable contains data saved from ck-editor. It is displayed along with the tags.


Solution

  •    <%=@my_variable.html_safe%>