Home

sandipransing edited this page Sep 13, 2010 · 6 revisions
Clone this wiki locally

RailsTinyMCE

A Tiny MCE Rich text Editor for ruby on rails applications.

  1. Plugin Features

1. Provides ease to add TinyMCE editor in rails forms
2. Easily configurable external plugins for editor using YML file
3. Plugin provides way to upload images and media from editor itself.
4. Uses paperclip upload with validations
5. s3 storage can be enabled

This plugin based on ja_tiny_mce plugin, thanks to ilake for his great job, i have modified and updated this plugin for our project needs, now this plugin workswith jrails(jquery), paperclip plugin.

1, Install rails_tiny_mce plugin using

ruby script/plugin install git://github.com/sandipransing/rails_tiny_mce.git

ruby script/generate rails_tiny_mce_migration
rake db:migrate

2, Install dependent plugins(if you didn’t):

rake rails_tiny_mce:plugins

The command will pull paperclip, responds_to_parent, will_paginate to your plugin directory

paperclip : git://github.com/thoughtbot/paperclip.git
responds_to_parent : http://responds-to-parent.googlecode.com/svn/trunk
will_paginate : git://github.com/mislav/will_paginate.git

3, Install jrails(jquery) plugin using
script/plugin install git://github.com/aaronchi/jrails.git

4, Add following lines inside layout:
<%= javascript_include_tag :defaults >
<
= javascript_include_tiny_mce_if_used >
<
= tiny_mce if using_tiny_mce? %>

5, Add following lines in controller file where Editor needs to be added:
(just like before_filter):

uses_tiny_mce(:options => AppConfig.default_mce_options, :only => [:new, :edit])

This AppConfig.default_mce_options is in config/initializers/tiny_mce_plus_config.rb, you could change the setting there

6. In your view form
Then append the following to the text area you want to transform into a TinyMCE editor.

:class => “mceEditor” like <%= f.text_area :description, :class => “mceEditor” %>

7. Install file lists

rake rails_tiny_mce:install

will Install following files:

app
|— controller
|— attachments_controller.rb
|— helpers
|— remote_link_renderer.rb
|— models
|— print.rb
|— video.rb
|— views
|— attachments
|— show_attachment_list.html.erb
config
|— initializers
|— tiny_mce_plus
config.rb

public
|— images
|— tiny_mce
|— javascripts
|— tiny_mce

You may custom the config in tiny_mce_plus_config.rb.

  1. Attention:
    1, do not put

    around the textarea.
    2, If you use old will_paginate plugin, maybe change the url_for to url_option in remote_link_renderer.rb
  1. Example use:

1, Create CRUD for post
ruby script/generate scaffold post title:string text:description

2, Run migrations
rake db:migrate

3, Add following line to posts_controller.rb
uses_tiny_mce(:options => AppConfig.default_mce_options, :only => [:new, :edit])

4, Open /views/posts/new.html.erb and /views/posts/edit.html.erb
Modifiy following line
<%= f.text_area :description >
to
<
= f.text_area :description, :class => “mceEditor” %>

thats, all

any sugestions? san2821 at gmail.com, sandip at joshsoftware.com released under the MIT license