-
Notifications
You must be signed in to change notification settings - Fork 134
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.
- 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.
- 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
- https://devcenter.heroku.com/articles/cdn-asset-host-rails31
- http://infinitemonkeys.influitive.com/blog/2012/11/09/who-serves-your-assets/
- http://stackoverflow.com/questions/10745998/rails-how-to-upload-precompiled-assets-to-cloudfront
- http://ryantownsend.co.uk/post/13126016608/cloudfront-cdn-on-rails