TinyMCE (WYSIWYG) for Ruby on Rails 11

Posted by John Wulff Thu, 01 Jun 2006 00:45:00 GMT

Blake Watters has just created a TinyMCE plugin for Ruby on Rails.

How-To integrate TinyMCE into your Rails app (assumes you’re using svn).

  1. Add the plugin to your svn:externals and get the latest code.
    $ cd MyRailsApp
    $ script/plugin install -x https://secure.near-time.com/svn/plugins/trunk/tiny_mce
  2. Add the following to your application.rhtml
    <% # Include TinyMCE before other JS to avoid problems -%>
    <%= javascript_include_tiny_mce_if_used %>
    <%= tiny_mce if using_tiny_mce? %>
  3. Install the JavaScript
    $ rake tiny_mce:scripts:install
  4. Activate TinyMCE for a controller. (Uses TinyMCE for any TextArea).
    class MyController < ApplicationController
      uses_tiny_mce
      ...
That is it! Not too much work for full featured WYSIWYG eh? Now, to really make it sing try this.
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,
  :paste_auto_cleanup_on_paste => true,
  :theme_advanced_buttons1 => %w{formatselect fontselect fontsizeselect bold italic underline strikethrough separator justifyleft justifycenter justifyright indent outdent separator bullist numlist forecolor backcolor separator link unlink image undo redo},
  :theme_advanced_buttons2 => [],
  :theme_advanced_buttons3 => [],
  :plugins => %w{contextmenu paste}},
  :only => [:new, :edit, :show, :index])

Awesome work Blake.

UPDATE: This info is now in the Ruby on Rails Wiki.

Trackbacks

Use the following link to trackback from your own site:
http://www.johnwulff.com/trackbacks?article_id=tinymce-with-ruby-on-rails&day=31&month=05&year=2006

Comments

Leave a comment

  1. Avatar
    Peter LD about 1 year later:
    I think this line: $ script/install -x https://secure.near-time.com/svn/plugins/trunk/tiny_mce should read: $ ./script/plugin install -x https://secure.near-time.com/svn/plugins/trunk/tiny_mce
  2. Avatar
    John Wulff about 1 year later:
    Thanks Peter.
  3. Avatar
    Swe Zin about 1 year later:
    I start learning Ruby on Rail and use Window OS. I do not know some differences between Window Command Prompt and Mac OS. For this example, I typed as following: ruby script/plugin install -x https://secure.near-time.com/svn/plugins/trunk/tiny_mce Then, it got this error message: Cannot install using subversion because `svn' cannot be found in your PATH Could you explain me step by step for Window users? Where should I put the script? Thanks
  4. Avatar
    Mikkel about 1 year later:
    Hi.. I've installed you plugin and it works just fine. Just one question. When i make a normal textarea it works, but when the textarea is located in a partially rendered page, only the normal textarea appears. how can i init tinymce after the page is rendered..??
  5. Avatar
    Ivor about 1 year later:
    Hi. is there any support to allow beter image uploads? Is there a ruby image browser? Can I use something like ibrowser with this plugin
  6. Avatar
    Image Selector Plugin for TinyMCE & Rails about 1 year later:
    Hi - thanks for this create tutorial! It helped us get started with Tiny MCE and ruby on rails. We've also been able to create an image selector for TinyMCE so that our users can select from a list of previously uploaded images, instead of copying and pasting URLs. Hopefully, we can return the favor with our How-To as well! How to Create an Image Selection Plugin for tinyMCE with Ruby on Rails
  7. Avatar
    Yi Wen about 1 year later:
    Is there any plan that the plugin will upgrade to use the newest tinyMCE? (now it's 3.0a3)
  8. Avatar
    juju about 1 year later:
    I love these "do in 2 minutes" things :)
  9. Avatar
    jagaa120@gmail.com about 1 year later:
    Thanks Jagaa.
  10. Avatar
    Piyush Patil(pypiyush@gmail.com) about 1 year later:
    Hello Friends, I have implemented tiny_mce in my ruby on rails application. And the HTML editing window which we get with all the buttons is being displayed two times on the same page.. I have only one text_area tag on my view page But still I am getting two text formatting boxes on the view page. Do You have any idea about this issue..? Thanks Piyush
  11. Avatar
    Ric over 2 years later:
    Please check out my simple alternative for using TinyMCE on rails, which doesn't tie you into a specific version.
Comments


h %s", link_to ('scribbish', 'http://quotedprintable.com/pages/scribbish'))%>