TinyMCE bold not working in rails

908 Views Asked by At

I have used Tinymce editor in my rails app. When I try to make a text bold and save, the text changes are not reflected.

Gemfile

gem 'tinymce-rails'

congig/tinymce.yml

selector: textarea.table-editor
theme: modern
selector: textarea
toolbar: styleselect | bold italic | undo redo | table | alignleft 
         aligncenter alignright alignjustify | bullist numlist outdent indent | ink image | print preview media fullpage | forecolor backcolor | emoticons
plugins:
      - table 
      - advlist autolink link image lists charmap print preview hr anchor  pagebreak spellchecker
      - searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking 
      - save table contextmenu directionality emoticons template paste textcolor 

application.js

 //= require tinymce

something.html.erb

 <%= tinymce_assets %>
 <%= tinymce %>
 <%= form.text_area :description, :class => "tinymce", id: :course_description %> 

show.html.erb

 <%= @course.description.html_safe %>
1

There are 1 best solutions below

5
On

Normally all these wysiwyg editors format your input in to html, markdown etc under the hood and saves to the data base.

If we consider html, when you make a text bold, for an example it maybe adding a <b></b> tag around your text.

I can see you have the code plugin in the list. As per the documentation of the plugin, it should allow you to view the html of your editing changes.

As a test,

  • Make a text bold in the editor
  • Switch to Source view and see if your text is surrounded by bold tags.

  • If yes, make sure you backend saves the same string in to the database. Make sure you dont have any code that strips out the html tags

  • If no, then the editor is not converting your changes, you may have to check the editor configs.