Rails 3.1.2 ckeditor 供应商脚本
我有一个与这个问题中列举的问题类似的问题,除了我没有使用<代码>ckeditor gem.我直接使用 CKEditor 脚本。
我已将它们直接提取到 vendor/assets/javascripts/ckeditor
中,并将这些包含节添加到相应的 javascript 清单文件中:
//= require ckeditor/ckeditor
//= require ckeditor/adapters/jquery
在开发中,它工作得很好 — 我认为是因为 Rails 直接为资产提供服务。在生产中(当我将本地开发服务器切换到生产环境时),编辑器不会加载(只是像上面链接的问题那样的空格),并且我收到如下加载错误:
这些路径显然是错误的,现在我想起来,我什至不确定它在开发中是如何工作的。
有没有人让这个设置正常工作,或者我应该接受它并像其他人一样使用宝石?
I have a similar problem to the one enumerated in this question, except I am not using the ckeditor
gem. I am using the CKEditor scripts directly.
I have extracted them directly into vendor/assets/javascripts/ckeditor
, and added these include stanzas to the appropriate javascript manifest file:
//= require ckeditor/ckeditor
//= require ckeditor/adapters/jquery
In development, it works perfectly fine — I assume because Rails is serving the assets directly. In production (and when I switch my local dev server to the production environment), the editor doesn't load (just blank spaces like the question linked above) and I get load errors like these:
Those paths are obviously wrong and I'm not sure how it's working even in dev now that I think about it.
Has anybody gotten this setup to work properly, or should I suck it up and just use the gem like everybody else seems to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时的修补后,我发现我的问题有两个。
首先,您可以设置一个 CKEditor 全局选项来告诉它基本安装路径所在的位置。为了进行设置,我更改了
application.js
以添加这两行:其次,我的环境配置未设置为预编译几个 CKEditor 文件。因此,在 config/environments/development.rb 中,我将 ckeditor/config.js 和 ckeditor/contents.css 添加到我的文件数组中正在传递给
config.assets.precompile
。编辑:我必须在预编译列表中添加更多文件,而不仅仅是此处列出的文件。全面的列表可能会产生误导,因为大多数文件都来自自定义主题。加载 Chrome Inspector 或 Firebug 并查看仍然返回 404 的资源列表,将它们添加到数组中,重新编译,然后查看是否修复了该问题,这相当简单。
After a few hours of tinkering, I figured out that my problem was two-fold.
First, there is a CKEditor global option you can set to tell it where the base install path resides. To set that, I altered my
application.js
to add these two lines:Second, my environment config wasn't set to precompile a couple of the CKEditor files. So in
config/environments/production.rb
, I addedckeditor/config.js
andckeditor/contents.css
to the array of files I'm passing toconfig.assets.precompile
.EDIT: I had to add a few more files to the precompile list than just the ones listed here. A comprehensive list would be misleading, since most of those files were from a custom theme. It's fairly simple to load up Chrome Inspector or Firebug and look at the list of assets that are still coming back 404, add those to the array, recompile, and see if that fixed it.