Live preview of formatted HTML form input with Rails
问题 I want a feature of previewing some text with HTML tags and then storing the text in database. I know it is not a good idea to allow HTML in database, for XSS security reasons. What are the ways to achieve this? I want a feature similar to the one we have in stackoverflow, where we can format our sourcecodes. Thanks. 回答1: Recommended way: Create an javascript event listener for the form on your html-page. Submit the input via ajax to your rails app, where the input gets rendered (for example