Setting up tiny_mce_plus plugin in rails application

I recently had to struggle with setting up tiny_mce_plugin and spend a whole day trying to get it working. Troubleshooting it was very difficult since tiny_mce_plus plugin has dependencies on other plugins ( mentioned below) and there was no one place where everything was laid out to make it to work. I had to really dig in. The last step is the most important.

The following are the steps I had used to make it work on windows.

  1. Install ImageMagick: Download from I had downloaded the zip version and extracted it in a directory. Make sure you set the PATH variable in your system environment to point to that dir.
  2. Install Mini Magick Plugin : Download from I had downloaded the zip version and extracted it in a directory. All that is needed is one file mini_magick.rb. You can put this in your applications lib directory. If you are installing a plugin then the plugin will be in vendor/plugins directory.
  3. Install tiny_mce_plus: The following process uses git. Git for windows can be downloaded from Install git and then do the following:
    cd vendor/plugins 
    git clone git:// script/generate tiny_mce_plus_migration 
    rake db:migrate rake tiny_mce_plus:install
  4. Install tiny_mce_plus plugins:tiny_mce_plus is dependent on 3 plugins. Install these plugins, preferably from the package bundled with tiny_mce_plus.
  5. rake tiny_mce_plus:plugin  
    The above command will install the plugins. 
    If you want to install them individually, the following are the location. 
    attachment_fu:  git:// 
    will_paginate:  git://
  6. Authentication: tiny_mce_plus works on the premise that only authenticated users can be allowed to add rich text. The tiny_mce_model has an association with user. It uses login_required and current_user methods. It is preferred that you install the restful_authentication plugin. 
  7. Javascript setings: Add the following in the layout view right above any other javascript directives.
  8. <%= javascript_include_tiny_mce_if_used %> 
    <%= tiny_mce if using_tiny_mce? %> 
    <%= javascript_include_tag :defaults %>
  9. Controller settings:You need to make the controller which will be using the tiny_mce_plus to be aware of it by adding the following in the applicable controller.
  10. uses_tiny_mce(:options => AppConfig.default_mce_options, :only => [:new, :edit])
  11. tiny_mce_model changes:This is the most important of all changes. This took me a whole lot of time to figure out. My save operation on tiny_mce_mode had been failing and was not giving me meaningful error [DEPRECATION WARNING: ActiveRecord::Errors.default_error_messages has been deprecated. Please use I18n.translate(‘activerecord.errors.messages’).. (called from default_error_messages at C:/data/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/validations.rb:24)]. I had to use debugger to do some serious debugging. It was failing during validation in the attachment_fu plugin. The method validates_as_attachment in tiny_mce_model was tripping. After some research on the net found out that the :size option of the has_attachment method is mandatory and if not supplied gives validation error. The has_attachment options as used in the tiny_mce_module will not work. The following is what I have in my tiny_mce_mode ( what i added is in blue).
  12. has_attachment :storage => :file_system, 
        :content_type => [:image, 'application/x-shockwave-flash'], 
        :max_size => 5.megabytes, 
        :size => 0.megabyte..5.megabytes,
        :resize_to => '600x>', 
        :thumbnails => {:thumb => "100>", :medium => "290x320>", :large => "664>"}, 
        :processor => 
        :MiniMagick, :path_prefix => 'public/tiny_mce'

That is it. You are all set. So long…



Tags: , , , , , , , , , , , , , , , , , , , , ,

Comments are closed.