TinyMCE for Ruby on Rails

tinymce

TinyMCE is a WYSIWYG editor controll for web browsers. This explains how to do a fresh installation of the tiny_mce plugin for Ruby on Rails.

Get the source

Open a console, and go to the root of your Rails application, install the plugin by running the following, for installation with subversion:

script/plugin install -x https://secure.near-time.com/svn/plugins/trunk/tiny_mce

Then copy the necessary files into your public directory by running while in your root

rake tiny_mce:install

Include TinyMCE in selected pages

Add the following to the controller of the page you want to add the TinyMCE editor to.

uses_tiny_mce

Then append the following to the text area you want to transform into a TinyMCE editor.

:class => "mceEditor"

Lastly, add the following line(s) to the <head> element of your application view, layout view:

<%= include_tiny_mce_if_needed %>

That’s about it! It’s time for some advanced options. Edit the uses_tiny_mce controller command and add some hashed-based options.

uses_tiny_mce(:options => {
    :theme => 'advanced',
    :browsers => %w{msie gecko},
    :theme_advanced_toolbar_location => "top",
    :theme_advanced_toolbar_align => "left",
    :theme_advanced_resizing => true,
    :theme_advanced_resize_horizontal => false,
    :theme_advanced_statusbar_location=>"bottom",
    :paste_auto_cleanup_on_paste => true,
    :theme_advanced_buttons1 => %w{formatselect emotions fullscreen bold italic underline separator justifyleft justifycenter justifyright indent outdent | cleanup help code},
    :theme_advanced_buttons2 => [],
    :theme_advanced_buttons3 => [],
    :plugins => %w{contextmenu emotions fullscreen paste}},
  :content_css => "css/content.css",
  :only => [:new, :edit, :show, :index])