Skip to content

Work with asset host

tsechingho edited this page Feb 23, 2013 · 2 revisions

There are some issues needed to consider.

The value of CKEDITOR_BASEPATH will be fixed when ckeditor-jquery.js is compiled by assets pipeline since it requires ckeditor/base_path.js.erb.

  1. If you only have one assets host, you may have config/environments/production.rb
config.action_controller.asset_host = "https://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"

or with CDN

config.action_controller.asset_host = "//d1aar6ipvvlxt7.cloudfront.net"

and it is ok to have fixed asset host for CKEDITOR_BASEPATH.

<%
base_path = ''
base_path << Rails.application.config.action_controller.asset_host
base_path << Rails.application.config.assets.prefix
base_path << '/ckeditor/'
%>
var CKEDITOR_BASEPATH = '<%= base_path %>';

You can create app/assets/javascripts/ckeditor/basepath.js.erb to have your own CKEDITOR_BASEPATH.

  1. If you have dynamic assets hosts, you may have config/environments/production.rb
config.action_controller.asset_host = "http://asset%d.example.com"

You need to dynamic change assets host by javascript for CKEDITOR.basePath not CKEDITOR_BASEPATH.

And basepath.js.erb should not include Rails.application.config.action_controller.asset_host.

<%
base_path = ''
base_path << Rails.application.config.assets.prefix
base_path << '/ckeditor/'
%>
var CKEDITOR_BASEPATH = '<%= base_path %>';

Otherwise it would produce wrong CKEDITOR_BASEPATH like http://asset%d.example.com/assets/ckeditor/

also see

Clone this wiki locally