【发布时间】:2015-08-05 05:59:29
【问题描述】:
我想要一个自定义的 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 %>';
但是,当我转到其他页面时,我在控制台中看到了错误。 GET 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/assets/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”获取
【问题讨论】:
-
我把demo站点做生产了,你可以用这个测试账号看看失败。 cmpt470.csil.sfu.ca:8010/tutorsaround (email: 1@ta.com 密码:11111111) 登录后可以到下面的链接在评论中查看加载失败。 cmpt470.csil.sfu.ca:8010/tutorsaround/boards/new
标签: ruby-on-rails ckeditor ckeditor4.x