0

Additionally if I want to store HTML in that text_area how can I render it as HTML?

Thanks,

Alex

1 Answer 1

1

Not entirely sure what you are asking for. But the basics are:

Your text area should most likely be linked to a an attribute of type TEXT so you are not limited in the size. See the migration guide for details.

As for storing straight HTML, it's dangerous to let user input arbitrary HTML content, specially if it's going to be seen by other user (for example on a forum) as it would allow anybody to add javascript to the page. This is also known as XSS or Cross site scripting. Think of at least of sanitizing the input.

To display the "raw" HTML content, in Rails 3 you need to add .html_safe to your attribute. This mean Rails will not clean it up and will render the content as is in the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.