0

我想要一个自定义的 CKEDITOR_BASEPATH 作为参考https://github.com/galetahub/ckeditor

我的应用程序在 baseURL 上运行,如下所示 http://localhost:3000/tutorsaround

因此,我将“app/assets/javascripts/ckeditor/basepath.js.erb”更改为

<%
  base_path = '/tutorsaround'
  if ENV['PROJECT'] =~ /editor/i
    base_path << "/#{Rails.root.basename.to_s}/"
  end
  base_path << Rails.application.config.assets.prefix
  base_path << '/ckeditor/'
  puts "#{base_path}"
%>
var CKEDITOR_BASEPATH = '<%= base_path %>';

但是,当我转到不同的页面时,我在控制台中看到了一个错误。获取http://localhost:3000/tutorsaround/boards/tutorsaround/assets/ckeditor/config.js?t=F0RD 404(未找到)

似乎在每个子路径之后插入了路径,而不是http://localhost:3000/

所以我的问题是如何为 CKeditor 添加一个 base_path 基本 url 将始终为http://localhost:3000/tutorsaround并且每当它想要引用 js 源时,它将是http://localhost:3000/tutorsaround /资产/ckeditor/ ......

EDIT2 我将base_path 放在它输出“tutorsaround/assets/ckeditor/”的终端中我的问题是这个字符串在“localhost:3000/”之后没有连接。但是,任何使用 CKEditor 的页面都会在页面 url 上连接此字符串。例如,如果“localhost:3000/boards”有CK编辑器,那么它会尝试通过“ http://localhost:3000/boards/tutorsaround/assets/ckeditor/config.js?t=F0RD ”获取资源" 如果 "localhost:3000/boards/1" 已经使用了 CKEditor,那么它会尝试从 " http://localhost:3000/boards/1/tutorsaround/assets/ckeditor/config.js?t=F0RD 获取"

4

1 回答 1

0

编辑: 请再次检查下面的代码示例,因为最初我发布它们时没有您的自定义路径前缀

尝试删除条件(将行留在其中):

<%
  base_path = '/tutorsaround'
  base_path << "/#{Rails.root.basename.to_s}/"
  base_path << Rails.application.config.assets.prefix
  base_path << '/ckeditor/'
 %>

或者如果这不起作用,请尝试:

<%
  base_path = '/tutorsaround'
  base_path << Rails.application.config.assets.prefix
  base_path << '/ckeditor/'
%>

编辑2

app/assets/javascripts/application.jsinit 之前添加基本路径依赖项:

//= require ckeditor/basepath
//= require ckeditor/init
于 2015-08-05T06:37:54.310 回答