Ckeditor integration gem for Active Admin
Ruby JavaScript
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 2 commits ahead, 263 commits behind galetahub:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.



CKEditor is a ready-for-use HTML text editor designed to simplify web content creation. It's a WYSIWYG editor that brings common word processor features directly to your web pages. Enhance your website experience with our community maintained editor.


  • Ckeditor version 4.1.2 (full)

  • Rails 3.2 integration

  • Files browser

  • HTML5 files uploader

  • Hooks for formtastic and simple_form forms generators


For basic usage just include ckeditor gem:

gem "ckeditor"

For files uploading support you need generage models for file storage. Currently supported next backends:

  • ActiveRecord (paperclip, carrierwave, dragonfly)

  • Mongoid (paperclip, carrierwave, dragonfly)

How generate models for store uploading files

ActiveRecord + paperclip

For active_record orm is used paperclip gem (it's by default).

gem "paperclip"

rails generate ckeditor:install --orm=active_record --backend=paperclip

ActiveRecord + carrierwave

gem "carrierwave"
gem "mini_magick"

rails generate ckeditor:install --orm=active_record --backend=carrierwave

Mongoid + paperclip

gem 'mongoid-paperclip', :require => 'mongoid_paperclip'

rails generate ckeditor:install --orm=mongoid --backend=paperclip

Mongoid + carrierwave

gem "carrierwave-mongoid", :require => 'carrierwave/mongoid'
gem "mini_magick"

rails generate ckeditor:install --orm=mongoid --backend=carrierwave

Load generated models

All ckeditor models will be generated into app/models/ckeditor folder. Autoload ckeditor models folder (application.rb):

config.autoload_paths += %W(#{config.root}/app/models/ckeditor)

Mount engine in your routes (config/routes.rb):

mount Ckeditor::Engine => "/ckeditor"


Include ckeditor javascripts rails 3.2 (application.js):

//= require ckeditor/init

Form helpers:

<%= form_for @page do |form| -%>
  <%= form.cktext_area :notes, :class => "someclass", :ckeditor => {:language => "uk"} %>
  <%= form.cktext_area :content, :value => "Default value", :id => "sometext" %>
  <%= cktext_area :page, :info, :ckeditor => {:uiColor => "#AADC6E", :toolbar => "mini"} %>
<% end -%>

All ckeditor 4.0 options here!/api/CKEDITOR.config

In order to configure the ckeditor default options, create files:




jQuery sample:

<script type='text/javascript' charset='UTF-8'>
    $('form[data-remote]').bind("ajax:before", function(){
      for (instance in CKEDITOR.instances){

Formtastic integration

<%= form.input :content, :as => :ckeditor %>
<%= form.input :content, :as => :ckeditor, :input_html => { :ckeditor => { :height => 400 } } %>

SimpleForm integration

<%= form.input :content, :as => :ckeditor, :input_html => { :ckeditor => {:toolbar => 'Full'} } %>

CanCan integration

To use cancan with Ckeditor, add this to an initializer.

# in config/initializers/ckeditor.rb

Ckeditor.setup do |config|
  config.authorize_with :cancan

At this point, all authorization will fail and no one will be able to access the filebrowser pages. To grant access, add this to Ability#initialize

# Always performed
can :access, :ckeditor   # needed to access Ckeditor filebrowser

# Performed checks for actions:
can [:read, :create, :destroy], Ckeditor::Picture
can [:read, :create, :destroy], Ckeditor::AttachmentFile


    page_title: "CKEditor Files Manager"
    confirm_delete: "Delete file?"
      cancel: "Cancel"
      upload: "Upload"
      delete: "Delete"


rake test
rake test CKEDITOR_ORM=mongoid
rake test CKEDITOR_BACKEND=carrierwave

rake test:controllers
rake test:generators
rake test:integration
rake test:models

This project rocks and uses MIT-LICENSE.