我ckeditor
在我的 Rails 应用程序中使用了 ruby gem (v4.2.2),它在开发中运行良好,但在我的production
环境中却不行。我的资产管道看起来没有问题,因为所有其他资产加载时都没有任何问题。
在页面上,谷歌浏览器给了我这个错误:
Uncaught TypeError: Cannot set property 'dir' of undefined
而 Firefox 只是在控制台中抛出这个:
TypeError: c[a] is undefined[Learn More]
到目前为止我已经尝试过:
- 在
Uglifier.new(mangle: false)
Sprockets 中用作 JS 压缩器 - 手动设置
CKEDITOR_BASEPATH
rake asset:precompile
in all生成的资产文件public/assets/ckeditor
在末尾都有一个哈希,如下所示:
ckeditor-e0b9bfe15298d2b2dd388960b27d35e6a18c89b2390f8986d398c30da5496e4b.js
config-1fb318e1cc0eea7b8c181941c3c1f09d2b96107b2f7ff4891755fbb2201ba53d.js
contents-4540cf2cb7116b32bac2995494c4fc0c55804444f37c02cfa11256bd695e4194.css
# etc
但 JS 似乎并没有加载它们并试图现在修复它。
代码
我的 Javascript 文件:
//= require pages-javascript
//= require ckeditor/init
//= require_tree ./ckeditor
//= require_self
资产初始化器:
# config/initializers/assets.rb
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.precompile << Proc.new do |filename, full_path|
if filename =~ /\.(css|js|svg|eot|woff|ttf)\z/
app_assets_path = Rails.root.join('app', 'assets').to_s
if full_path.starts_with? app_assets_path
Rails.logger.info "including asset: " + full_path
true
else
Rails.logger.info "excluding asset: " + full_path
false
end
else
false
end
end
Rails.application.config.assets.precompile += %w( ckeditor/* )