So I installed this implementation of tinymce-rails gem:
- Added
gem 'tinymce-rails'
to the Gemfile and ranbundle install
- Configured
//= require tinymce-jquery
inapp/assets/javascripts/application.js
. - Messed around to get tinymce to see i am on a sub-uri (config.relative_url_root in config/application.rb)
- Ran
bundle exec rake assets:precompile
for production added this to my form:
<%= f.label :body %>
$(function() { $('.mceEditor').tinymce({ theme: 'advanced', plugins : 'table', theme_advanced_buttons1 : 'bold,italic,underline,strikethrough,|,bullist,numlist,outdent,indent,|,forecolor,backcolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect', theme_advanced_buttons2 : 'undo,redo,|,link,unlink,image,blockquote,hr,|,tablecontrols', theme_advanced_buttons3 : '', theme_advanced_toolbar_location : 'top', theme_advanced_statusbar_location : 'bottom', theme_advanced_resizing: true }); });
<%= f.text_area :body, :class => "mceEditor" %>
All works wonderfully! It's an awesome editor.
But, I don't want to liter that script code throughout my forms. Probably a dumb question. But where is the place to put this script code so it is globally (and automaticlally) going to be used on an text areas that are class "mceEditor".
Thanks!
app/views/layouts/application.html.erb
. But then it is included in every page, even where there is no editor. – peterept