lundi 24 août 2015

How do I show formatted text in rails text area?

I'm using rails form. In that form, I've a text_area. I want to show pre-filled data in text area of rails. The data is html content.

I tried following,

<% test_val= "<h1>Test Value</h1>" %>
<%= form.text_area(:myval, :value => test_val.html_safe, size: '30x10', :style => 'border: 10;') %>

myval is my form variable. But instead of printing Test Value in bold and bigger font in text area, t showed <h1>Test Value</h1>. I want the content in HTML tag to be printed with HTML formatting. Is it possible? If yes, how do I achieve it?

p.s. I'm using ruby v1.9.3 & rails 3.1.0

Aucun commentaire:

Enregistrer un commentaire