4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Railsでckeditorとasset_syncを併用する

Last updated at Posted at 2016-02-24

概要

問題

ckeditorのjavascriptがさらに別のjavascriptファイルを読み込もうとするが、ホスト名がs3でないため、jsのエラーが発生し、ckeditor自体が正常に動作しない。

解決

https://github.com/mkaszubowski/ckeditor#include-customized-ckeditor_basepath-setting
https://github.com/tsechingho/ckeditor-rails/wiki/Work-with-asset-host

↑を参考に
app/assets/javascripts/ckeditor/basepath.js.erb
を作成

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

これをapplication.jsなどでrequireするとs3からjavascriptファイルを読み込むようになる

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?