我想要一个自定义的 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 获取"