So, as far as I could gather, you want to display the actual unescaped HTML.
<%= raw post.content %>
Reference: raw (ActionView::Helpers::OutputSafetyHelper) - APIdock
Question
I'm using rails_admin in order to create wysiwyg editor for my Post model, which are essentially just blog posts. I have a content field and title field.
I've also included ckeditor in order to format the text of the content field. I'm trying to display each post in my view like so:
<% @posts.each do |post| %>
<div class="row text">
<%= post.title %>
<%= post.content %>
</div>
<% end %>
However, when displayed on the screen the content prints out all of the html tags that were added to the content by ckeditor. For example, if I increased the size of the text, or made a sentence bold or italic, it will print out all of the html and css code.
I'm hoping there is away to get the html to render to my erb files so that it is formatted automatically in the view for the user.
When I look in inspector the content is surrounded in quotes.
My railsadmin config file calls the Post model as such:
config.model Post do
edit do
field :title
field :content, :ck_editor
end
end
Thank you.
Solution
So, as far as I could gather, you want to display the actual unescaped HTML.
<%= raw post.content %>
Reference: raw (ActionView::Helpers::OutputSafetyHelper) - APIdock