Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
4 Posts
Tinymce 3.3.2

Could anyone tell me how I can integrate the latest version of tinymce in Rails?

1) Install gem using [sudo] gem install tiny_mce Then add this to config/environment.rb of your Rails application: config.gem 'tiny_mce'

Alternatively you can install plugin(instead of gem) using script/plugin install git://github.com/kete/tiny_mce.git

2) Add this line in the controller where you want to use TinyMCE uses_tiny_mce :options => {

                          :theme => 'advanced',
                          :theme_advanced_resizing => true,
                          :theme_advanced_resize_horizontal => false,
                          :plugins => %w{ table fullscreen }

Global Options

If you have a set of default options that is used throughout all editors in your application, you might want to make them global. You can do this by putting your settings into config/tiny_mce.yml. If the file exists, the tiny_mce plugin will parse the options in it first. Example

theme: advanced plugins: - table - fullscreen

You can read about all these options at: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration

3)Then append the following to the text area you want to transform into a TinyMCE editor. You can change the name of the class you want to use by editing the ‘editor_selector’ param in the controller code options.

:class => "mceEditor"

4) Lastly, add the following line(s) to the element of your application view i.e. the html.erb file where you want to include TinyMCE

I would advise against using the gem. Where I have done so in the past it's come back to bite me, since upgrading broke things and was cumbersome on the server. The gem is not officially maintained so you have to rely on someone else to maintain it for you.

Since tinymce is 100% javascript my preference is to keep it 100% separate from Rails.

I use jQuery for all rails websites, so I use the tinymce jQuery plugin, which you can download from http://tinymce.moxiecode.com/download.php (third item from the top). This has the advantage of loading tinymce in the background, which speeds up the page a lot, plus it only loads tinymce when it's actually needed.

4 Posts
Login to add your message