Godzilla74 Godzilla74 - 1 year ago 91
Ruby Question

Active Admin not parsing html correctly

I'm creating a blog with rails using activeadmin and active_admin_editor. The Blog table is simple:


When I add a blog post it shows the html tags, I need the tags to actually be parsed so blog posts actually look like a real html page.

I've also already tried a migration to change the content column to 'text' instead of a string... that didn't help.

This is what my posts look like right now:
enter image description here

What have I done wrong or missed here to get the html tags to render correctly?

** UPDATE **
After a suggestion to get the activeadmin view working, I'm still left with the raw html in the user view (non-admin user that can only view the blog)

enter image description here

Answer Source

You can customize the ActiveAdmin pages into admin/post.rb with something like:

ActiveAdmin.register Post do
  # ....
  index do
    # ...
    column (:content) { |post| raw(post.content) }
    # ...
  show do
    # ...
    row (:content) { |post| raw(post.content) }
    # ...

For your own views (ex: posts/show.html.erb), just use:


instead of


in your own view. 'raw' will show the content "as is", without escaping the HTML (which Rails is doing by default).