Rich is an opinionated WYSIWYG editor (based on CKEditor) for Rails 3.1 with flexible image uploads (using Paperclip).
Ruby JavaScript
Pull request Compare This branch is 268 commits behind kreativgebiet:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Rich is an opinionated implementation of CKEditor for Rails 3.1 and up. It includes a stripped down toolbar, simplified dialogs and a custom file manager.

Presently, Rich integrates with Active Admin, Rails Admin and vanilla Formtastic (versions 1 and 2).


  1. Keep the CKEditor source our of your project.

  2. Sensible defaults. We don't want our users to insert tables, smilies or other frivolities that will do nothing but ruin a lovingly crafted design.

  3. Make it easy to customize these defaults.

  4. Implement a usable (and easily configurable) file manager that serves up images that fit your specific design.

  5. A good upload experience (multiple uploads, progress bars, pure html/js).

It should be noted that while a major point of this project was to remove many things from CKEditor, all that stuff is still in there and can be easily re-enabled.

Dependency Status

Quick install

Rich is available as a Ruby Gem, which makes installation very easy.

# In your Gemfile (Rails >= 3.1)
gem 'rich'
# the edge (unstable) version can be had using:
# gem 'rich', :git => ''

After updating your bundle, run the installer.

$> rails generate rich:install

The installer sets up a route, creates an initializer for configuration and adds a javascript and CSS file. It also creates a migration, so we need to migrate the database.

$> rake db:migrate

As a last step, secure the file manager by setting your authentication method in /config/initializers/rich.rb. If you're using Devise with an AdminUser model (incidentally, the Active Admin defaults):

config.authentication_method = :authenticate_admin_user!

You're good to go.


Vanilla Formtastic

To use Rich, it's javascript file must be loaded. By default, this is already setup for you because Rails loads all Javascript files through the require_tree . command in application.js. If you've removed that line, manually load rich by requiring it.

//= require rich

In your formtastic form, use :as => :rich to insert Rich. Like so:

<%= semantic_form_for @post do |f| %>
   <%= f.inputs do %>
     <%= f.input :name %>
     <%= f.input :title %>
     <%= f.input :body, :as => :rich, :config => { :default_style => "myCrazyPaperclipStyle" } %>
   <% end %>
   <%= f.buttons do %>
     <%= f.commit_button %>
   <% end %>
 <% end %>

Active Admin

Since Active Admin actually uses Formtastic, you can use it with Rich out of the box. In your model configuration file, set up your form like this. Make sure you add //= require rich to your app/assets/javascripts/active_admin.js.

form do |f|
  f.inputs "Basic info" do
    f.input :title
    f.input :body, :as => :rich, :config => { :width => '76%', :height => '400px' }

If you're annoyed by the fact that the Rich editor overlaps the field label (I was!), add the following to your /app/assets/stylesheets/active_admin.css.scss.

#wrapper .cke_skin_kama {
	margin-left: 20%;

Rails Admin

To use Rich in your RA forms, first add the following lines to your /config/initializers/rails_admin.rb.

require 'rich/integrations/rails_admin_editor'

This will enable the rich_editor field type. You can use this field as follows:

config.model Post do
  edit do
    field :title
    field :body, :rich_editor do
         :insert_many => true 


This is the editor with default settings.

This is the file manager.

Rich in production mode

Rich works just fine in production mode. To accomodate the structure of the CKEditor source, Rich extends the assets:precompile task to make sure the full CKEditor source tree is copied to your assets folder. So the following works as you would expect:

rake assets:precompile

Rich will also clean up these CKEditor files when you clean your assets. Like this:

rake assets:clean

Although generally not necessary, the underlying Rich tasks can be invoked directly.

rake rich:assetize_ckeditor
rake rich:clean_ckeditor

Configuration and overrides

Take a look at the generated rich.rb initializer and – if you want to dig deeper – the Rich sourcecode. The initializer guides you through the most important settings and configuration options.


Localization should be automatic. Rich uses the currently set locale (I18n.locale) for it's editor and file browser.

CKEditor configuration

Rich attempts to provide you with a sensible set of buttons and capabilities. But of course, you might disagree. To that end, you can configure CKEditor through the config directive, either globally through the initializer, or per editor instance as an option.

Rich also includes a few settings that manipulate CKEditor settings, but are a bit easier to use. For example, you can set :allow_embeds to true to load a media embed plugin (think Youtube, Vimeo, etc.)

Editor styles

When you run the generator a css file is created for you in app/assets/stylesheets/rich/editor.css. Use this stylesheet to define the contents of the Styles drop down in CKEditor.

Image configuration

The styles you define in the initializer are passed to Paperclip directly, so the syntax is identical. See for more information.

When you change styles after uploading files, you will need to re-process those old files. To accomplish this, run the following command (avoid the standard Paperclip task!).

rake rich:refresh_assets

Planned features

  • scoping assets to other objects

  • drag & drop uploading

  • finding/filtering assets

  • live image cropping

  • live image rotation


Tools used


Your contributions (small and large) are very welcome! Please fork the project, make your changes and send me a pull request. If you are considering adding new functionality, or if you found a bug, please open an issue on Github first.


Rich was created by Bastiaan Terhorst and is sponsored by Perceptor (

This project is licenced under the MIT License. See MIT-LICENSE for details.