Rails activeadmin integrated CKEditor 5
Add this line to your application's Gemfile:
gem 'activeadmin_ckeditor5'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install activeadmin_ckeditor5
ActiveAdmin.register Article do
#...
form do |f|
f.inputs 'Article' do
f.input :title, label: 'title'
f.input :content, as: :ckeditor, label: 'content'
end
actions
end
#...
end
Define uploading route
#config/routes.rb
post :uploads, to: 'uploads#create'
Then define upload controller
class UploadsController < ApplicationController
def create
#TODO
end
end
You will get a Can't verify CSRF token authenticity
error when you uploading image
You can redefine csrf_meta_tag
location
# config/initializers/active_admin_layout.rb
module AdminPageLayoutOverride
def build_active_admin_head
within head do
# CKEditor simpleUpload components will use csrfToken, but can't find csrf_meta_tag when loading js
# so the csrf_meta_tag is generated in advance here.
text_node csrf_meta_tag
end
super
end
end
ActiveAdmin::Views::Pages::Base.send :prepend, AdminPageLayoutOverride
Or skip verify authenticity token
class AdminUploadsController < AdminApplicationController
skip_forgery_protection
def create
#TODO
end
end