How to add ckeditor to active admin on Rails

1. Gemfile

gem ‘activeadmin’, github: ‘activeadmin’
gem ‘devise’
gem ‘paperclip’
gem ‘ckeditor’#, github: ‘galetahub/ckeditor’

bundle install
rails generate active_admin:install
rake db:migrate 

2. /config/initializers/active_admin.rb

# To load a javascript file:
config.register_javascript 'ckeditor/init.js'

 

3. rails g scaffold project name:title description:text
rake db:migrate

 

4. rails generate active_admin:resource project
5. Edit app/admin/project.rb
ActiveAdmin.register Project do

permit_params :title, :description

form do |f|
  f.inputs do
    f.input :title
    f.input :description, :as => :ckeditor
  end
end

end
6. Add to app/assets/stylesheets/active_admin.css.scss:
.cke_chrome {
  width: 79.5% !important;
  overflow: hidden;
}
7. Add to app/assets/javascripts/active_admin.js:
var CKEDITOR_BASEPATH = '/assets/ckeditor/';

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s