ckeditor: "CKEDITOR_BASEPATH" doesn't work correctly

Using

Rails 5.0.0.1 ruby 2.3.1p112 ckeditor-4.2.0

Bug

Even though CKEDITOR_BASEPATH is /assets/ckeditor, ckeditor is still searching assets/javascript/ckeditor.

For example,

When I put my downloaded skin at /assets/ckeditor/skins, the console gives me this 404 error screenshot 2016-12-08 14 31 15

It looks like searching under /assets/ckeditor/skins. However, when I put my skin /assets/javascripts/ckeditor/skins, it works.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 16

Most upvoted comments

Exact problem I had the other day, spent 2 days fixing.

You need to reset the tmp cache:

rake assets:clobber
rake tmp:clear
rake assets:precompile

Should fix it.

Alternatively, you can explicitly define the basepath as per these instructions;

# app/assets/javascripts/ckeditor/basepath.js.erb
<%
  base_path = ''
  base_path << "/#{Rails.root.basename.to_s}/" if ENV['PROJECT'] =~ /editor/i
  base_path << Rails.application.config.assets.prefix
  base_path << '/ckeditor/'
%>

var CKEDITOR_BASEPATH = '<%= base_path %>';

Another issue you will have is with Sprockets.

Since skins have an .md file by default, using link_tree (which is required for Sprockets 4+) will return an exception. You need to ensure you have registered the .md mime_type:

# config/application.rb
# => Markdown (for CKEditor)
# => https://github.com/rails/sprockets/blob/99444c0a280cc93e33ddf7acfe961522dec3dcf5/guides/extending_sprockets.md#register-mime-types
config.before_initialize do |app|
  Sprockets.register_mime_type 'text/markdown', extensions: ['.md']
end

This also goes for any other unconventional extensions that may exist in the skins.

R

@richpeck Wow, thank you for giving me the solution!