I am using ruby on rails 3.2.1. For my post formatting I want to use TinyMCE, but I have problem with it.
- I have installed tinymce gem and restarted server.
- Downloaded tinymce and putted it in \myapp name\app\assets
-
My application head:
<head> <title>Līvu pamatskola</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <%= stylesheet_link_tag 'style' %> <%= javascript_include_tag "application" %> <%= csrf_meta_tag %> <script type="text/javascript" src="D:/Projects/Myapp name/app/assets/tinymce/jscripts/tiny_mce/tiny_mce.js" ></script> <script type="text/javascript" > tinyMCE.init({ mode : "textareas", theme : "simple" }); </script> </head> -
Made /MyApp name/config/tinymce.yml file with:
theme_advanced_toolbar_location: top theme_advanced_toolbar_align: left theme_advanced_statusbar_location: bottom theme_advanced_buttons3_add: - tablecontrols - fullscreen plugins: - table - fullscreen -
In /MyApp name/app/assets/javascripts/application.js
//= require tinymce-jquery
In result I have nice formatting panel @post content field, but after saving post I can see text with html tags, not formated text. I think there is problems with installation.
It sounds as though your view is automatically escaping the html parts of your @post content field.
In your view you can do
<%= raw @post.content %>or<%= @post.content.html_safe %>You can read this rails guide about outputting html safely http://guides.rubyonrails.org/active_support_core_extensions.html#output-safety and this stackoverflow post about the differences between raw and html_safe raw vs. html_safe vs. h to unescape html