ActionText is displaying with html tags when displayed in rails 6

438 views Asked by At

I tried looking around but couldnt find an answer to this. The only post I found that resembles my problem is here: Action Text displaying html tags However when I try to use the sanetize method I just get another error "no implicit conversion of ActionText::RichText into String" so I would really just like to fix the original problem of the html tags displaying to begin with. Here is what it currently looks like: enter image description here

Added has_rich_text to comment module:

class Comment < ApplicationRecord
  belongs_to :user
  belongs_to :post
  validates :body, presence: true, allow_blank: false
  has_rich_text :body
end

Added imports into application.js:

import "trix"
import "@rails/actiontext"

Added import to actiontext.scss: @import "trix/dist/trix";

Added import to application.css.scss: @import "./actiontext.scss";

Added rich text area to form:

 <%= form_with model: [@post, @comment], local: true do |f| %>
    <%= f.rich_text_area :body, class: 'form-control greyh' %>
    <%= f.submit 'Comment', class: 'btn btn-success' %>
 <% end %>

And finally here is how it's being displayed:

<%="[#{comment.created_at.strftime("%I :%M %p")}] #{comment.user.username}: #{comment.body}" %>

I am not sure what else to try at this point . Any help is appreciated.

0

There are 0 answers