Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add skin to ckeditor in Rails?

I've to install CKEditor in my Rails project but the buttons on the default skin are all misaligned. See:

enter image description here

So I'm trying to install the Bootstrap skin to fix this and also because it fits better with the rest of my website.

I've downloaded the files and put under

app/assets/ckeditor/skins/bootstrapkg

And changed config/ckeditor.rb to add:

  config.asset_path = Rails.application.config.assets.prefix

But when I try to add the method config.assets_skins or config.skins I get

NoMethodError:: undefined method `skin=' for Ckeditor:Module

I've tried config.skins, config.skinName but nothing works.

When I try to create a app/assets/ckeditor/config.js and put

config.skin = 'bootstrapkg';

... the editor stops showing.

In my rails server log, I can still see calls for the 'moono' skin instead of the Bootstrap one.

So, how do I install another theme to CKEditor on Rails (I can also accept a fix for the misaligned buttons)?

like image 749
Hugo Carlos Avatar asked Jul 11 '15 11:07

Hugo Carlos


1 Answers

the thing here is that you need to place the skin folder on the public folder and not in the assets folder because it will be precompiled and will have the timestamp in the name, so when ckeditor try to get the file at app/assets/ckeditor/skins/bootstrapkg, the file has the name of bootstrapkg1234354 you get the point. So, place the skin folder on

/public/assets/ckeditor/skins/

and then on your file /app/assets/javascripts/ckeditor/config.js you can add simply

CKEDITOR.editorConfig = function( config ){

  config.skin = 'bootstrapkg';

};

or the skin you want to add and that's all, it will work like a charm.

like image 178
xploshioOn Avatar answered Sep 19 '22 18:09

xploshioOn