Skip to content

Ckeditor integration

rmagnum2002 edited this page Apr 5, 2012 · 12 revisions

To use CKEDitor in Active Admin, you need to do four things:

  1. Add Ckeditor to your Gemfile
gem 'ckeditor'

for rails 3.2 use this

gem "ckeditor", "3.7.0.rc3"
  1. Add the ckeditor stylesheet to active admin (in config/initializers/active_admin.rb)
config.register_javascript 'ckeditor/ckeditor.js'
  1. Change your form to a partial
ActiveAdmin.register User do
  form :partial => "user_form"
  1. Add the ckeditor class to your input field in the partial (in admin/users/_user_form.html.haml) (HAML style code)
= semantic_form_for [:admin, @user] do |f|
  = f.input :description, :input_html => {:class => :ckeditor}
  = f.submit

a) If you don't want to use haml-syntax, you could also do this (in admin/users/_user_form.html.erb)

<%= semantic_form_for [:admin, @user] do |f| %>
  <%= f.input :description, :input_html => {:class => :ckeditor} %>
  <%= f.submit %>
<% end %>

Presto! You're done :-)

Or you can do in your ActiveAdmin model

ActiveAdmin.register Product do

form do |f|
  f.inputs "Details", :multipart => true do
    f.input :title

  f.inputs "Content" do
    f.input :description, :input_html => { :class => "ckeditor" }
  end
  f.buttons
end

end

Clone this wiki locally