Search code examples
htmlruby-on-railsrubyblogs

How to get html to render on blog posts


I have a blog that saves input from html input tags, saves them as XML into a sqlite3 database, and then finally renders the content inside of this tag.

<p>
  <b>Content:</b>
  <%= @post.content %>
</p>

I need this .content to be able to render HTML. Any ideas?


Solution

  • For these kind of situations, you have to use either:

    Using CKEditor is a breeze with the CKEditor gem

    And please note if you are using Rails 3, you need to explicitly say you want raw HTML, like this:

    <p>
      <b>Content:</b>
      <%= raw @post.content %>
    </p>