TinyMCE Hammer : A Ruby on Rails Plugin

TinyMCE Hammer (tinymce_hammer) is a Ruby On Rails plugin that makes it easy to add Moxiecode's rich text editor to your forms. The tinymce_hammer plugin requires Ruby on Rails 2.3 or better.

I developed tinymce_hammer in my work with LuxuryRealEstate.com. It is currently in use on a large number of member facing pages and performs admirably. We choose to load TinyMCE using this plugin with ajax (we lazy load it).

Plugin Features

Easy to use
Two-step installation and you are ready to go. Form helpers are provided for most common cases.
Need to lazy load TinyMCE w/javascript? Need two different editors on the same page? Want to user your own form helpers? No problem.
TinyMCE requests lots of .js files for the most basic of editor configurations. It does all this over XMLHttpRequest. tinymce_hammer eliminates this by combining all required library files (plugins, themes, languages, etc) into one javascript file.

Getting Started

This is a quick-start guide to getting a TinyMCE editor in your Rails application. You can find more examples / tutorials here.


  1. Download (zip, tgz) the tinymce_hammer plugin and copy it to:


  2. Run:

    script/generate tinymce_installation

    The default install path is RAILS_ROOT/public/javascripts/tiny_mce. See configuration for help with changing the installation path.

Basic Usage

Now we need to enable TinyMCE with the following function, just call it somewhere in your layout (inside the head tags, at the end of the document, etc).

    <title>Lazy Load Example</title>
    <%= init_tinymce_hammer_if_required %>

The method above will insert a pair of script tags whenever there is a TinyMCE editor on the page. It knows to do this anytime you use one of the 3 basic helpers. Each of these helpers behave exactly like their text_area cousins. They even accept the same parameters.

<%= tinymce_tag('comment', 'Your comment goes here ...') %>
<%= tinymce(:comment, :body) %>
<%- form_for @comment do |form| -%>
  <%= form.label :body %>
  <%= form.tinymce :body %>
<% end %>

Next Step

Now that you are up and running you probably want to customize how the TinyMCE editor looks and acts for your website.

Next tutorial, configuring TinyMCE with TinyMCEHammer